<!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>[13775] CalendarServer/trunk</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/13775">13775</a></dd>
<dt>Author</dt> <dd>gaya@apple.com</dd>
<dt>Date</dt> <dd>2014-07-17 14:54:34 -0700 (Thu, 17 Jul 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>allow sharing calendars to groups</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#CalendarServertrunkproject">CalendarServer/trunk/.project</a></li>
<li><a href="#CalendarServertrunkcalendarserverpushtesttest_notifierpy">CalendarServer/trunk/calendarserver/push/test/test_notifier.py</a></li>
<li><a href="#CalendarServertrunkcalendarservertoolsprincipalspy">CalendarServer/trunk/calendarserver/tools/principals.py</a></li>
<li><a href="#CalendarServertrunkconfcaldavdtestplist">CalendarServer/trunk/conf/caldavd-test.plist</a></li>
<li><a href="#CalendarServertrunktwistedcaldavsharingpy">CalendarServer/trunk/twistedcaldav/sharing.py</a></li>
<li><a href="#CalendarServertrunktwistedcaldavstdconfigpy">CalendarServer/trunk/twistedcaldav/stdconfig.py</a></li>
<li><a href="#CalendarServertrunktxdavcaldavdatastoresqlpy">CalendarServer/trunk/txdav/caldav/datastore/sql.py</a></li>
<li><a href="#CalendarServertrunktxdavcaldavdatastoretesttest_sql_externalpy">CalendarServer/trunk/txdav/caldav/datastore/test/test_sql_external.py</a></li>
<li><a href="#CalendarServertrunktxdavcaldavdatastoretesttest_sql_sharingpy">CalendarServer/trunk/txdav/caldav/datastore/test/test_sql_sharing.py</a></li>
<li><a href="#CalendarServertrunktxdavcaldavicalendarstorepy">CalendarServer/trunk/txdav/caldav/icalendarstore.py</a></li>
<li><a href="#CalendarServertrunktxdavcarddavdatastoretesttest_sql_sharingpy">CalendarServer/trunk/txdav/carddav/datastore/test/test_sql_sharing.py</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastorefilepy">CalendarServer/trunk/txdav/common/datastore/file.py</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastorepoddingtesttest_conduitpy">CalendarServer/trunk/txdav/common/datastore/podding/test/test_conduit.py</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastorepoddingtestutilpy">CalendarServer/trunk/txdav/common/datastore/podding/test/util.py</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoresqlpy">CalendarServer/trunk/txdav/common/datastore/sql.py</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoresql_schemacurrentoracledialectsql">CalendarServer/trunk/txdav/common/datastore/sql_schema/current-oracle-dialect.sql</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoresql_schemacurrentsql">CalendarServer/trunk/txdav/common/datastore/sql_schema/current.sql</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoresql_tablespy">CalendarServer/trunk/txdav/common/datastore/sql_tables.py</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoreworktesttest_revision_cleanuppy">CalendarServer/trunk/txdav/common/datastore/work/test/test_revision_cleanup.py</a></li>
<li><a href="#CalendarServertrunktxdavwhoaugmentpy">CalendarServer/trunk/txdav/who/augment.py</a></li>
<li><a href="#CalendarServertrunktxdavwhogroupspy">CalendarServer/trunk/txdav/who/groups.py</a></li>
<li><a href="#CalendarServertrunktxdavwhotesttest_group_attendeespy">CalendarServer/trunk/txdav/who/test/test_group_attendees.py</a></li>
<li><a href="#CalendarServertrunktxdavwhotesttest_groupspy">CalendarServer/trunk/txdav/who/test/test_groups.py</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li>CalendarServer/trunk/txdav/caldav/datastore/test/accounts/</li>
<li><a href="#CalendarServertrunktxdavcommondatastoresql_schemaoldoracledialectv45sql">CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v45.sql</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoresql_schemaoldpostgresdialectv45sql">CalendarServer/trunk/txdav/common/datastore/sql_schema/old/postgres-dialect/v45.sql</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoresql_schemaupgradesoracledialectupgrade_from_45_to_46sql">CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_45_to_46.sql</a></li>
<li><a href="#CalendarServertrunktxdavcommondatastoresql_schemaupgradespostgresdialectupgrade_from_45_to_46sql">CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/postgres-dialect/upgrade_from_45_to_46.sql</a></li>
<li><a href="#CalendarServertrunktxdavwhotestaccountsgroupAccountsxml">CalendarServer/trunk/txdav/who/test/accounts/groupAccounts.xml</a></li>
<li><a href="#CalendarServertrunktxdavwhotesttest_group_shareespy">CalendarServer/trunk/txdav/who/test/test_group_sharees.py</a></li>
</ul>

<h3>Removed Paths</h3>
<ul>
<li><a href="#CalendarServertrunktxdavwhotestaccountsgroupAttendeeAccountsxml">CalendarServer/trunk/txdav/who/test/accounts/groupAttendeeAccounts.xml</a></li>
</ul>

<h3>Property Changed</h3>
<ul>
<li><a href="#CalendarServertrunk">CalendarServer/trunk/</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalendarServertrunk"></a>
<div class="propset"><h4>Property changes: CalendarServer/trunk</h4>
<pre class="diff"><span>
</span></pre></div>
<a id="svnmergeinfo"></a>
<div class="modfile"><h4>Modified: svn:mergeinfo</h4></div>
<span class="cx">/CalendarServer/branches/config-separation:4379-4443
</span><span class="cx">/CalendarServer/branches/egg-info-351:4589-4625
</span><span class="cx">/CalendarServer/branches/generic-sqlstore:6167-6191
</span><span class="cx">/CalendarServer/branches/new-store:5594-5934
</span><span class="cx">/CalendarServer/branches/new-store-no-caldavfile:5911-5935
</span><span class="cx">/CalendarServer/branches/new-store-no-caldavfile-2:5936-5981
</span><span class="cx">/CalendarServer/branches/release/CalendarServer-4.3-dev:10180-10190,10192
</span><span class="cx">/CalendarServer/branches/release/CalendarServer-5.1-dev:11846
</span><span class="cx">/CalendarServer/branches/release/CalendarServer-5.2-dev:11972,12357-12358,12794,12814
</span><span class="cx">/CalendarServer/branches/users/cdaboo/batchupload-6699:6700-7198
</span><span class="cx">/CalendarServer/branches/users/cdaboo/cached-subscription-calendars-5692:5693-5702
</span><span class="cx">/CalendarServer/branches/users/cdaboo/component-set-fixes:8130-8346
</span><span class="cx">/CalendarServer/branches/users/cdaboo/cross-pod-sharing:12038-12191
</span><span class="cx">/CalendarServer/branches/users/cdaboo/directory-cache-on-demand-3627:3628-3644
</span><span class="cx">/CalendarServer/branches/users/cdaboo/fix-no-ischedule:11607-11871
</span><span class="cx">/CalendarServer/branches/users/cdaboo/implicituidrace:8137-8141
</span><span class="cx">/CalendarServer/branches/users/cdaboo/ischedule-dkim:9747-9979
</span><span class="cx">/CalendarServer/branches/users/cdaboo/json:11622-11912
</span><span class="cx">/CalendarServer/branches/users/cdaboo/managed-attachments:9985-10145
</span><span class="cx">/CalendarServer/branches/users/cdaboo/more-sharing-5591:5592-5601
</span><span class="cx">/CalendarServer/branches/users/cdaboo/partition-4464:4465-4957
</span><span class="cx">/CalendarServer/branches/users/cdaboo/performance-tweaks:11824-11836
</span><span class="cx">/CalendarServer/branches/users/cdaboo/pods:7297-7377
</span><span class="cx">/CalendarServer/branches/users/cdaboo/pycalendar:7085-7206
</span><span class="cx">/CalendarServer/branches/users/cdaboo/pycard:7227-7237
</span><span class="cx">/CalendarServer/branches/users/cdaboo/queued-attendee-refreshes:7740-8287
</span><span class="cx">/CalendarServer/branches/users/cdaboo/relative-config-paths-5070:5071-5105
</span><span class="cx">/CalendarServer/branches/users/cdaboo/reverse-proxy-pods:11875-11900
</span><span class="cx">/CalendarServer/branches/users/cdaboo/scheduling-queue-refresh:11783-12557
</span><span class="cx">/CalendarServer/branches/users/cdaboo/shared-calendars-5187:5188-5440
</span><span class="cx">/CalendarServer/branches/users/cdaboo/sharing-in-the-store:11935-12016
</span><span class="cx">/CalendarServer/branches/users/cdaboo/store-scheduling:10876-11129
</span><span class="cx">/CalendarServer/branches/users/cdaboo/timezones:7443-7699
</span><span class="cx">/CalendarServer/branches/users/cdaboo/txn-debugging:8730-8743
</span><span class="cx">/CalendarServer/branches/users/gaya/cleanrevisions:12152-12334
</span><span class="cx">/CalendarServer/branches/users/gaya/sharedgroupfixes:12120-12142
</span><span class="cx">/CalendarServer/branches/users/gaya/sharedgroups-3:11088-11204
</span><span class="cx">/CalendarServer/branches/users/glyph/always-abort-txn-on-error:9958-9969
</span><span class="cx">/CalendarServer/branches/users/glyph/case-insensitive-uid:8772-8805
</span><span class="cx">/CalendarServer/branches/users/glyph/conn-limit:6574-6577
</span><span class="cx">/CalendarServer/branches/users/glyph/contacts-server-merge:4971-5080
</span><span class="cx">/CalendarServer/branches/users/glyph/dalify:6932-7023
</span><span class="cx">/CalendarServer/branches/users/glyph/db-reconnect:6824-6876
</span><span class="cx">/CalendarServer/branches/users/glyph/deploybuild:7563-7572
</span><span class="cx">/CalendarServer/branches/users/glyph/digest-auth-redux:10624-10635
</span><span class="cx">/CalendarServer/branches/users/glyph/disable-quota:7718-7727
</span><span class="cx">/CalendarServer/branches/users/glyph/dont-start-postgres:6592-6614
</span><span class="cx">/CalendarServer/branches/users/glyph/enforce-max-requests:11640-11643
</span><span class="cx">/CalendarServer/branches/users/glyph/hang-fix:11465-11491
</span><span class="cx">/CalendarServer/branches/users/glyph/imip-and-admin-html:7866-7984
</span><span class="cx">/CalendarServer/branches/users/glyph/ipv6-client:9054-9105
</span><span class="cx">/CalendarServer/branches/users/glyph/launchd-wrapper-bis:11413-11436
</span><span class="cx">/CalendarServer/branches/users/glyph/linux-tests:6893-6900
</span><span class="cx">/CalendarServer/branches/users/glyph/log-cleanups:11691-11731
</span><span class="cx">/CalendarServer/branches/users/glyph/migrate-merge:8690-8713
</span><span class="cx">/CalendarServer/branches/users/glyph/misc-portability-fixes:7365-7374
</span><span class="cx">/CalendarServer/branches/users/glyph/more-deferreds-6:6322-6368
</span><span class="cx">/CalendarServer/branches/users/glyph/more-deferreds-7:6369-6445
</span><span class="cx">/CalendarServer/branches/users/glyph/multiget-delete:8321-8330
</span><span class="cx">/CalendarServer/branches/users/glyph/new-export:7444-7485
</span><span class="cx">/CalendarServer/branches/users/glyph/one-home-list-api:10048-10073
</span><span class="cx">/CalendarServer/branches/users/glyph/oracle:7106-7155
</span><span class="cx">/CalendarServer/branches/users/glyph/oracle-nulls:7340-7351
</span><span class="cx">/CalendarServer/branches/users/glyph/other-html:8062-8091
</span><span class="cx">/CalendarServer/branches/users/glyph/parallel-sim:8240-8251
</span><span class="cx">/CalendarServer/branches/users/glyph/parallel-upgrade:8376-8400
</span><span class="cx">/CalendarServer/branches/users/glyph/parallel-upgrade_to_1:8571-8583
</span><span class="cx">/CalendarServer/branches/users/glyph/q:9560-9688
</span><span class="cx">/CalendarServer/branches/users/glyph/queue-locking-and-timing:10204-10289
</span><span class="cx">/CalendarServer/branches/users/glyph/quota:7604-7637
</span><span class="cx">/CalendarServer/branches/users/glyph/sendfdport:5388-5424
</span><span class="cx">/CalendarServer/branches/users/glyph/shared-pool-fixes:8436-8443
</span><span class="cx">/CalendarServer/branches/users/glyph/shared-pool-take2:8155-8174
</span><span class="cx">/CalendarServer/branches/users/glyph/sharedpool:6490-6550
</span><span class="cx">/CalendarServer/branches/users/glyph/sharing-api:9192-9205
</span><span class="cx">/CalendarServer/branches/users/glyph/skip-lonely-vtimezones:8524-8535
</span><span class="cx">/CalendarServer/branches/users/glyph/sql-store:5929-6073
</span><span class="cx">/CalendarServer/branches/users/glyph/start-service-start-loop:11060-11065
</span><span class="cx">/CalendarServer/branches/users/glyph/subtransactions:7248-7258
</span><span class="cx">/CalendarServer/branches/users/glyph/table-alias:8651-8664
</span><span class="cx">/CalendarServer/branches/users/glyph/uidexport:7673-7676
</span><span class="cx">/CalendarServer/branches/users/glyph/unshare-when-access-revoked:10562-10595
</span><span class="cx">/CalendarServer/branches/users/glyph/use-system-twisted:5084-5149
</span><span class="cx">/CalendarServer/branches/users/glyph/uuid-normalize:9268-9296
</span><span class="cx">/CalendarServer/branches/users/glyph/warning-cleanups:11347-11357
</span><span class="cx">/CalendarServer/branches/users/glyph/whenNotProposed:11881-11897
</span><span class="cx">/CalendarServer/branches/users/glyph/xattrs-from-files:7757-7769
</span><span class="cx">/CalendarServer/branches/users/sagen/applepush:8126-8184
</span><span class="cx">/CalendarServer/branches/users/sagen/inboxitems:7380-7381
</span><span class="cx">/CalendarServer/branches/users/sagen/locations-resources:5032-5051
</span><span class="cx">/CalendarServer/branches/users/sagen/locations-resources-2:5052-5061
</span><span class="cx">/CalendarServer/branches/users/sagen/move2who:12819-12860
</span><span class="cx">/CalendarServer/branches/users/sagen/move2who-2:12861-12898
</span><span class="cx">/CalendarServer/branches/users/sagen/move2who-3:12899-12913
</span><span class="cx">/CalendarServer/branches/users/sagen/move2who-4:12914-13157
</span><span class="cx">/CalendarServer/branches/users/sagen/move2who-5:13158-13163
</span><span class="cx">/CalendarServer/branches/users/sagen/newcua:13309-13327
</span><span class="cx">/CalendarServer/branches/users/sagen/newcua-1:13328-13330
</span><span class="cx">/CalendarServer/branches/users/sagen/purge_old_events:6735-6746
</span><span class="cx">/CalendarServer/branches/users/sagen/recordtypes:13648-13656
</span><span class="cx">/CalendarServer/branches/users/sagen/recordtypes-2:13657
</span><span class="cx">/CalendarServer/branches/users/sagen/resource-delegates-4038:4040-4067
</span><span class="cx">/CalendarServer/branches/users/sagen/resource-delegates-4066:4068-4075
</span><span class="cx">/CalendarServer/branches/users/sagen/resources-2:5084-5093
</span><span class="cx">/CalendarServer/branches/users/sagen/testing:10827-10851,10853-10855
</span><span class="cx">/CalendarServer/branches/users/wsanchez/transations:5515-5593
</span><span class="cx">   + /CalDAVTester/trunk:11193-11198
</span><span class="cx">/CalendarServer/branches/config-separation:4379-4443
</span><span class="cx">/CalendarServer/branches/egg-info-351:4589-4625
</span><span class="cx">/CalendarServer/branches/generic-sqlstore:6167-6191
</span><span class="cx">/CalendarServer/branches/new-store:5594-5934
</span><span class="cx">/CalendarServer/branches/new-store-no-caldavfile:5911-5935
</span><span class="cx">/CalendarServer/branches/new-store-no-caldavfile-2:5936-5981
</span><span class="cx">/CalendarServer/branches/release/CalendarServer-4.3-dev:10180-10190,10192
</span><span class="cx">/CalendarServer/branches/release/CalendarServer-5.1-dev:11846
</span><span class="cx">/CalendarServer/branches/release/CalendarServer-5.2-dev:11972,12357-12358,12794,12814
</span><span class="cx">/CalendarServer/branches/users/cdaboo/batchupload-6699:6700-7198
</span><span class="cx">/CalendarServer/branches/users/cdaboo/cached-subscription-calendars-5692:5693-5702
</span><span class="cx">/CalendarServer/branches/users/cdaboo/component-set-fixes:8130-8346
</span><span class="cx">/CalendarServer/branches/users/cdaboo/cross-pod-sharing:12038-12191
</span><span class="cx">/CalendarServer/branches/users/cdaboo/directory-cache-on-demand-3627:3628-3644
</span><span class="cx">/CalendarServer/branches/users/cdaboo/fix-no-ischedule:11607-11871
</span><span class="cx">/CalendarServer/branches/users/cdaboo/implicituidrace:8137-8141
</span><span class="cx">/CalendarServer/branches/users/cdaboo/ischedule-dkim:9747-9979
</span><span class="cx">/CalendarServer/branches/users/cdaboo/json:11622-11912
</span><span class="cx">/CalendarServer/branches/users/cdaboo/managed-attachments:9985-10145
</span><span class="cx">/CalendarServer/branches/users/cdaboo/more-sharing-5591:5592-5601
</span><span class="cx">/CalendarServer/branches/users/cdaboo/partition-4464:4465-4957
</span><span class="cx">/CalendarServer/branches/users/cdaboo/performance-tweaks:11824-11836
</span><span class="cx">/CalendarServer/branches/users/cdaboo/pods:7297-7377
</span><span class="cx">/CalendarServer/branches/users/cdaboo/pycalendar:7085-7206
</span><span class="cx">/CalendarServer/branches/users/cdaboo/pycard:7227-7237
</span><span class="cx">/CalendarServer/branches/users/cdaboo/queued-attendee-refreshes:7740-8287
</span><span class="cx">/CalendarServer/branches/users/cdaboo/relative-config-paths-5070:5071-5105
</span><span class="cx">/CalendarServer/branches/users/cdaboo/reverse-proxy-pods:11875-11900
</span><span class="cx">/CalendarServer/branches/users/cdaboo/scheduling-queue-refresh:11783-12557
</span><span class="cx">/CalendarServer/branches/users/cdaboo/shared-calendars-5187:5188-5440
</span><span class="cx">/CalendarServer/branches/users/cdaboo/sharing-in-the-store:11935-12016
</span><span class="cx">/CalendarServer/branches/users/cdaboo/store-scheduling:10876-11129
</span><span class="cx">/CalendarServer/branches/users/cdaboo/timezones:7443-7699
</span><span class="cx">/CalendarServer/branches/users/cdaboo/txn-debugging:8730-8743
</span><span class="cx">/CalendarServer/branches/users/gaya/cleanrevisions:12152-12334
</span><span class="cx">/CalendarServer/branches/users/gaya/groupsharee2:13669-13773
</span><span class="cx">/CalendarServer/branches/users/gaya/sharedgroupfixes:12120-12142
</span><span class="cx">/CalendarServer/branches/users/gaya/sharedgroups-3:11088-11204
</span><span class="cx">/CalendarServer/branches/users/glyph/always-abort-txn-on-error:9958-9969
</span><span class="cx">/CalendarServer/branches/users/glyph/case-insensitive-uid:8772-8805
</span><span class="cx">/CalendarServer/branches/users/glyph/conn-limit:6574-6577
</span><span class="cx">/CalendarServer/branches/users/glyph/contacts-server-merge:4971-5080
</span><span class="cx">/CalendarServer/branches/users/glyph/dalify:6932-7023
</span><span class="cx">/CalendarServer/branches/users/glyph/db-reconnect:6824-6876
</span><span class="cx">/CalendarServer/branches/users/glyph/deploybuild:7563-7572
</span><span class="cx">/CalendarServer/branches/users/glyph/digest-auth-redux:10624-10635
</span><span class="cx">/CalendarServer/branches/users/glyph/disable-quota:7718-7727
</span><span class="cx">/CalendarServer/branches/users/glyph/dont-start-postgres:6592-6614
</span><span class="cx">/CalendarServer/branches/users/glyph/enforce-max-requests:11640-11643
</span><span class="cx">/CalendarServer/branches/users/glyph/hang-fix:11465-11491
</span><span class="cx">/CalendarServer/branches/users/glyph/imip-and-admin-html:7866-7984
</span><span class="cx">/CalendarServer/branches/users/glyph/ipv6-client:9054-9105
</span><span class="cx">/CalendarServer/branches/users/glyph/launchd-wrapper-bis:11413-11436
</span><span class="cx">/CalendarServer/branches/users/glyph/linux-tests:6893-6900
</span><span class="cx">/CalendarServer/branches/users/glyph/log-cleanups:11691-11731
</span><span class="cx">/CalendarServer/branches/users/glyph/migrate-merge:8690-8713
</span><span class="cx">/CalendarServer/branches/users/glyph/misc-portability-fixes:7365-7374
</span><span class="cx">/CalendarServer/branches/users/glyph/more-deferreds-6:6322-6368
</span><span class="cx">/CalendarServer/branches/users/glyph/more-deferreds-7:6369-6445
</span><span class="cx">/CalendarServer/branches/users/glyph/multiget-delete:8321-8330
</span><span class="cx">/CalendarServer/branches/users/glyph/new-export:7444-7485
</span><span class="cx">/CalendarServer/branches/users/glyph/one-home-list-api:10048-10073
</span><span class="cx">/CalendarServer/branches/users/glyph/oracle:7106-7155
</span><span class="cx">/CalendarServer/branches/users/glyph/oracle-nulls:7340-7351
</span><span class="cx">/CalendarServer/branches/users/glyph/other-html:8062-8091
</span><span class="cx">/CalendarServer/branches/users/glyph/parallel-sim:8240-8251
</span><span class="cx">/CalendarServer/branches/users/glyph/parallel-upgrade:8376-8400
</span><span class="cx">/CalendarServer/branches/users/glyph/parallel-upgrade_to_1:8571-8583
</span><span class="cx">/CalendarServer/branches/users/glyph/q:9560-9688
</span><span class="cx">/CalendarServer/branches/users/glyph/queue-locking-and-timing:10204-10289
</span><span class="cx">/CalendarServer/branches/users/glyph/quota:7604-7637
</span><span class="cx">/CalendarServer/branches/users/glyph/sendfdport:5388-5424
</span><span class="cx">/CalendarServer/branches/users/glyph/shared-pool-fixes:8436-8443
</span><span class="cx">/CalendarServer/branches/users/glyph/shared-pool-take2:8155-8174
</span><span class="cx">/CalendarServer/branches/users/glyph/sharedpool:6490-6550
</span><span class="cx">/CalendarServer/branches/users/glyph/sharing-api:9192-9205
</span><span class="cx">/CalendarServer/branches/users/glyph/skip-lonely-vtimezones:8524-8535
</span><span class="cx">/CalendarServer/branches/users/glyph/sql-store:5929-6073
</span><span class="cx">/CalendarServer/branches/users/glyph/start-service-start-loop:11060-11065
</span><span class="cx">/CalendarServer/branches/users/glyph/subtransactions:7248-7258
</span><span class="cx">/CalendarServer/branches/users/glyph/table-alias:8651-8664
</span><span class="cx">/CalendarServer/branches/users/glyph/uidexport:7673-7676
</span><span class="cx">/CalendarServer/branches/users/glyph/unshare-when-access-revoked:10562-10595
</span><span class="cx">/CalendarServer/branches/users/glyph/use-system-twisted:5084-5149
</span><span class="cx">/CalendarServer/branches/users/glyph/uuid-normalize:9268-9296
</span><span class="cx">/CalendarServer/branches/users/glyph/warning-cleanups:11347-11357
</span><span class="cx">/CalendarServer/branches/users/glyph/whenNotProposed:11881-11897
</span><span class="cx">/CalendarServer/branches/users/glyph/xattrs-from-files:7757-7769
</span><span class="cx">/CalendarServer/branches/users/sagen/applepush:8126-8184
</span><span class="cx">/CalendarServer/branches/users/sagen/inboxitems:7380-7381
</span><span class="cx">/CalendarServer/branches/users/sagen/locations-resources:5032-5051
</span><span class="cx">/CalendarServer/branches/users/sagen/locations-resources-2:5052-5061
</span><span class="cx">/CalendarServer/branches/users/sagen/move2who:12819-12860
</span><span class="cx">/CalendarServer/branches/users/sagen/move2who-2:12861-12898
</span><span class="cx">/CalendarServer/branches/users/sagen/move2who-3:12899-12913
</span><span class="cx">/CalendarServer/branches/users/sagen/move2who-4:12914-13157
</span><span class="cx">/CalendarServer/branches/users/sagen/move2who-5:13158-13163
</span><span class="cx">/CalendarServer/branches/users/sagen/newcua:13309-13327
</span><span class="cx">/CalendarServer/branches/users/sagen/newcua-1:13328-13330
</span><span class="cx">/CalendarServer/branches/users/sagen/purge_old_events:6735-6746
</span><span class="cx">/CalendarServer/branches/users/sagen/recordtypes:13648-13656
</span><span class="cx">/CalendarServer/branches/users/sagen/recordtypes-2:13657
</span><span class="cx">/CalendarServer/branches/users/sagen/resource-delegates-4038:4040-4067
</span><span class="cx">/CalendarServer/branches/users/sagen/resource-delegates-4066:4068-4075
</span><span class="cx">/CalendarServer/branches/users/sagen/resources-2:5084-5093
</span><span class="cx">/CalendarServer/branches/users/sagen/testing:10827-10851,10853-10855
</span><span class="cx">/CalendarServer/branches/users/wsanchez/transations:5515-5593
</span><a id="CalendarServertrunkproject"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/.project (13774 => 13775)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/.project        2014-07-17 19:55:36 UTC (rev 13774)
+++ CalendarServer/trunk/.project        2014-07-17 21:54:34 UTC (rev 13775)
</span><span class="lines">@@ -3,19 +3,10 @@
</span><span class="cx">         &lt;name&gt;CalendarServer&lt;/name&gt;
</span><span class="cx">         &lt;comment&gt;&lt;/comment&gt;
</span><span class="cx">         &lt;projects&gt;
</span><del>-                &lt;project&gt;CalDAVClientLibrary&lt;/project&gt;
-                &lt;project&gt;cffi&lt;/project&gt;
-                &lt;project&gt;psutil&lt;/project&gt;
-                &lt;project&gt;pyasn1&lt;/project&gt;
</del><ins>+                &lt;project&gt;caldavclientlibrary&lt;/project&gt;
+                &lt;project&gt;kerberos&lt;/project&gt;
</ins><span class="cx">                 &lt;project&gt;pycalendar&lt;/project&gt;
</span><del>-                &lt;project&gt;pycparser&lt;/project&gt;
-                &lt;project&gt;pycrypto&lt;/project&gt;
-                &lt;project&gt;PyGreSQL&lt;/project&gt;
-                &lt;project&gt;python-ldap-2.3.13&lt;/project&gt;
-                &lt;project&gt;sqlparse&lt;/project&gt;
</del><span class="cx">                 &lt;project&gt;twextpy&lt;/project&gt;
</span><del>-                &lt;project&gt;Twisted&lt;/project&gt;
-                &lt;project&gt;zope.interface-4.0.3&lt;/project&gt;
</del><span class="cx">         &lt;/projects&gt;
</span><span class="cx">         &lt;buildSpec&gt;
</span><span class="cx">                 &lt;buildCommand&gt;
</span></span></pre></div>
<a id="CalendarServertrunkcalendarserverpushtesttest_notifierpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/calendarserver/push/test/test_notifier.py (13774 => 13775)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/calendarserver/push/test/test_notifier.py        2014-07-17 19:55:36 UTC (rev 13774)
+++ CalendarServer/trunk/calendarserver/push/test/test_notifier.py        2014-07-17 21:54:34 UTC (rev 13775)
</span><span class="lines">@@ -228,7 +228,7 @@
</span><span class="cx">     def test_shareWithNotifier(self):
</span><span class="cx"> 
</span><span class="cx">         calendar = yield self.calendarUnderTest(home=&quot;user01&quot;)
</span><del>-        yield calendar.inviteUserToShare(&quot;user02&quot;, _BIND_MODE_WRITE, &quot;&quot;)
</del><ins>+        yield calendar.inviteUIDToShare(&quot;user02&quot;, _BIND_MODE_WRITE, &quot;&quot;)
</ins><span class="cx">         self.assertEquals(
</span><span class="cx">             set(self.notifierFactory.history),
</span><span class="cx">             set([
</span><span class="lines">@@ -241,7 +241,7 @@
</span><span class="cx">         yield self.commit()
</span><span class="cx"> 
</span><span class="cx">         calendar = yield self.calendarUnderTest(home=&quot;user01&quot;)
</span><del>-        yield calendar.uninviteUserFromShare(&quot;user02&quot;)
</del><ins>+        yield calendar.uninviteUIDFromShare(&quot;user02&quot;)
</ins><span class="cx">         self.assertEquals(
</span><span class="cx">             set(self.notifierFactory.history),
</span><span class="cx">             set([
</span><span class="lines">@@ -258,7 +258,7 @@
</span><span class="cx">     def test_sharedCalendarNotifier(self):
</span><span class="cx"> 
</span><span class="cx">         calendar = yield self.calendarUnderTest(home=&quot;user01&quot;)
</span><del>-        shareeView = yield calendar.inviteUserToShare(&quot;user02&quot;, _BIND_MODE_WRITE, &quot;&quot;)
</del><ins>+        shareeView = yield calendar.inviteUIDToShare(&quot;user02&quot;, _BIND_MODE_WRITE, &quot;&quot;)
</ins><span class="cx">         yield shareeView.acceptShare(&quot;&quot;)
</span><span class="cx">         shareName = shareeView.name()
</span><span class="cx">         yield self.commit()
</span></span></pre></div>
<a id="CalendarServertrunkcalendarservertoolsprincipalspy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/calendarserver/tools/principals.py (13774 => 13775)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/calendarserver/tools/principals.py        2014-07-17 19:55:36 UTC (rev 13774)
+++ CalendarServer/trunk/calendarserver/tools/principals.py        2014-07-17 21:54:34 UTC (rev 13775)
</span><span class="lines">@@ -808,7 +808,7 @@
</span><span class="cx">                 )
</span><span class="cx"> 
</span><span class="cx">         print(&quot;Group members:&quot;)
</span><del>-        memberUIDs = yield txn.membersOfGroup(groupID)
</del><ins>+        memberUIDs = yield txn.groupMemberUIDs(groupID)
</ins><span class="cx">         for memberUID in memberUIDs:
</span><span class="cx">             record = yield directory.recordWithUID(memberUID)
</span><span class="cx">             print(prettyRecord(record))
</span></span></pre></div>
<a id="CalendarServertrunkconfcaldavdtestplist"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/conf/caldavd-test.plist (13774 => 13775)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/conf/caldavd-test.plist        2014-07-17 19:55:36 UTC (rev 13774)
+++ CalendarServer/trunk/conf/caldavd-test.plist        2014-07-17 21:54:34 UTC (rev 13775)
</span><span class="lines">@@ -892,6 +892,11 @@
</span><span class="cx">       &lt;dict&gt;
</span><span class="cx">             &lt;key&gt;Enabled&lt;/key&gt;
</span><span class="cx">             &lt;true/&gt;
</span><ins>+            &lt;key&gt;Groups&lt;/key&gt;
+            &lt;dict&gt;
+                    &lt;key&gt;Enabled&lt;/key&gt;
+                    &lt;true/&gt;
+            &lt;/dict&gt;
</ins><span class="cx">       &lt;/dict&gt;
</span><span class="cx">       &lt;key&gt;AddressBooks&lt;/key&gt;
</span><span class="cx">       &lt;dict&gt;
</span></span></pre></div>
<a id="CalendarServertrunktwistedcaldavsharingpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/twistedcaldav/sharing.py (13774 => 13775)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twistedcaldav/sharing.py        2014-07-17 19:55:36 UTC (rev 13774)
+++ CalendarServer/trunk/twistedcaldav/sharing.py        2014-07-17 21:54:34 UTC (rev 13775)
</span><span class="lines">@@ -131,7 +131,7 @@
</span><span class="cx"> 
</span><span class="cx">         # Remove all invitees
</span><span class="cx">         for invitation in (yield self._newStoreObject.allInvitations()):
</span><del>-            yield self._newStoreObject.uninviteUserFromShare(invitation.shareeUID)
</del><ins>+            yield self._newStoreObject.uninviteUIDFromShare(invitation.shareeUID)
</ins><span class="cx"> 
</span><span class="cx">         returnValue(True)
</span><span class="cx"> 
</span><span class="lines">@@ -293,7 +293,8 @@
</span><span class="cx">         else:
</span><span class="cx">             # Invited shares use access mode from the invite
</span><span class="cx">             # Get the access for self
</span><del>-            returnValue(invitationAccessFromBindModeMap.get(self._newStoreObject.shareMode()))
</del><ins>+            bindMode = yield self._newStoreObject.effectiveShareMode()
+            returnValue(invitationAccessFromBindModeMap.get(bindMode))
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><span class="lines">@@ -451,7 +452,7 @@
</span><span class="cx">         returnValue(adjusted_invitations)
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-    def inviteUserToShare(self, userid, cn, ace, summary, request):
</del><ins>+    def inviteUIDToShare(self, userid, cn, ace, summary, request):
</ins><span class="cx">         &quot;&quot;&quot; Send out in invite first, and then add this user to the share list
</span><span class="cx">             @param userid:
</span><span class="cx">             @param ace: Must be one of customxml.ReadWriteAccess or customxml.ReadAccess
</span><span class="lines">@@ -469,7 +470,7 @@
</span><span class="cx">         return self._processShareActionList(dl, resultIsList)
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-    def uninviteUserFromShare(self, userid, ace, request):
</del><ins>+    def uninviteUIDFromShare(self, userid, ace, request):
</ins><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         Send out in uninvite first, and then remove this user from the share list.
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="lines">@@ -515,7 +516,7 @@
</span><span class="cx">         if not sharee:
</span><span class="cx">             returnValue(False)
</span><span class="cx"> 
</span><del>-        result = (yield self._newStoreObject.inviteUserToShare(
</del><ins>+        result = (yield self._newStoreObject.inviteUIDToShare(
</ins><span class="cx">             sharee.principalUID(),
</span><span class="cx">             invitationBindModeFromXMLMap[type(ace)],
</span><span class="cx">             summary,
</span><span class="lines">@@ -538,7 +539,7 @@
</span><span class="cx">         else:
</span><span class="cx">             returnValue(False)
</span><span class="cx"> 
</span><del>-        result = (yield self._newStoreObject.uninviteUserFromShare(uid))
</del><ins>+        result = (yield self._newStoreObject.uninviteUIDFromShare(uid))
</ins><span class="cx"> 
</span><span class="cx">         returnValue(result)
</span><span class="cx"> 
</span><span class="lines">@@ -660,12 +661,12 @@
</span><span class="cx">                 del removeDict[u]
</span><span class="cx">                 del setDict[u]
</span><span class="cx">             for userid, access in removeDict.iteritems():
</span><del>-                result = (yield self.uninviteUserFromShare(userid, access, request))
</del><ins>+                result = (yield self.uninviteUIDFromShare(userid, access, request))
</ins><span class="cx">                 # If result is False that means the user being removed was not
</span><span class="cx">                 # actually invited, but let's not return an error in this case.
</span><span class="cx">                 okusers.add(userid)
</span><span class="cx">             for userid, (cn, access, summary) in setDict.iteritems():
</span><del>-                result = (yield self.inviteUserToShare(userid, cn, access, summary, request))
</del><ins>+                result = (yield self.inviteUIDToShare(userid, cn, access, summary, request))
</ins><span class="cx">                 (okusers if result else badusers).add(userid)
</span><span class="cx">             for userid, (cn, removeACL, newACL, summary) in updateinviteDict.iteritems():
</span><span class="cx">                 result = (yield self.inviteUserUpdateToShare(userid, cn, removeACL, newACL, summary, request))
</span></span></pre></div>
<a id="CalendarServertrunktwistedcaldavstdconfigpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/twistedcaldav/stdconfig.py (13774 => 13775)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twistedcaldav/stdconfig.py        2014-07-17 19:55:36 UTC (rev 13774)
+++ CalendarServer/trunk/twistedcaldav/stdconfig.py        2014-07-17 21:54:34 UTC (rev 13775)
</span><span class="lines">@@ -608,7 +608,7 @@
</span><span class="cx">     &quot;MaxBytesBatchUpload&quot;     : 10485760, # Maximum size of a batch POST (10 MB)
</span><span class="cx"> 
</span><span class="cx">     &quot;Sharing&quot;: {
</span><del>-        &quot;Enabled&quot;             : False, # Overall on/off switch
</del><ins>+        &quot;Enabled&quot;             : True, # Overall on/off switch
</ins><span class="cx">         &quot;AllowExternalUsers&quot;  : False, # External (non-principal) sharees allowed
</span><span class="cx"> 
</span><span class="cx">         &quot;Calendars&quot; : {
</span><span class="lines">@@ -629,9 +629,13 @@
</span><span class="cx">                 &quot;Global&quot;: [
</span><span class="cx">                 ],
</span><span class="cx">             },
</span><ins>+            &quot;Groups&quot; : {
+                &quot;Enabled&quot;     : False, # Calendar Group sharing on/off switch
+                &quot;ReconciliationDelaySeconds&quot; : 5,
+            },
</ins><span class="cx">         },
</span><span class="cx">         &quot;AddressBooks&quot; : {
</span><del>-            &quot;Enabled&quot;         : False, # Address Books on/off switch
</del><ins>+            &quot;Enabled&quot;         : False, # Address Book sharing on/off switch
</ins><span class="cx">             &quot;CollectionProperties&quot;: {
</span><span class="cx">                 &quot;Shadowable&quot;: [
</span><span class="cx">                     &quot;{urn:ietf:params:xml:ns:carddav}addressbook-description&quot;,
</span><span class="lines">@@ -642,7 +646,7 @@
</span><span class="cx">                 ],
</span><span class="cx">             },
</span><span class="cx">             &quot;Groups&quot; : {
</span><del>-                &quot;Enabled&quot;         : False, # Address Books on/off switch
</del><ins>+                &quot;Enabled&quot;      : False, # Address Book Group sharing on/off switch
</ins><span class="cx">             },
</span><span class="cx">         },
</span><span class="cx">     },
</span><span class="lines">@@ -1074,7 +1078,7 @@
</span><span class="cx">     },
</span><span class="cx"> 
</span><span class="cx">     &quot;GroupAttendees&quot; : {
</span><del>-        &quot;Enabled&quot;: False,
</del><ins>+        &quot;Enabled&quot;: True,
</ins><span class="cx">         &quot;ReconciliationDelaySeconds&quot; : 5,
</span><span class="cx">         &quot;UpdateOldEventLimitSeconds&quot; : 1 * 24 * 60 * 60,   # 1 day
</span><span class="cx">     },
</span></span></pre></div>
<a id="CalendarServertrunktxdavcaldavdatastoresqlpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/caldav/datastore/sql.py (13774 => 13775)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/caldav/datastore/sql.py        2014-07-17 19:55:36 UTC (rev 13774)
+++ CalendarServer/trunk/txdav/caldav/datastore/sql.py        2014-07-17 21:54:34 UTC (rev 13775)
</span><span class="lines">@@ -27,19 +27,15 @@
</span><span class="cx"> ]
</span><span class="cx"> 
</span><span class="cx"> from twext.enterprise.dal.record import fromTable
</span><del>-from twext.enterprise.dal.syntax import Delete
-from twext.enterprise.dal.syntax import Insert
-from twext.enterprise.dal.syntax import Len
-from twext.enterprise.dal.syntax import Parameter
-from twext.enterprise.dal.syntax import Select, Count, ColumnSyntax
-from twext.enterprise.dal.syntax import Update
-from twext.enterprise.dal.syntax import utcNowSQL
</del><ins>+from twext.enterprise.dal.syntax import Count, ColumnSyntax, Delete, \
+    Insert, Len, Max, Parameter, Select, Update, utcNowSQL
</ins><span class="cx"> from twext.enterprise.locking import NamedLock
</span><span class="cx"> from twext.enterprise.jobqueue import WorkItem
</span><span class="cx"> from twext.enterprise.util import parseSQLTimestamp
</span><span class="cx"> from twext.python.clsprop import classproperty
</span><span class="cx"> from twext.python.filepath import CachingFilePath
</span><span class="cx"> from twext.python.log import Logger
</span><ins>+from twext.who.idirectory import RecordType
</ins><span class="cx"> from twistedcaldav.ical import Component as VComponent
</span><span class="cx"> from txweb2.http_headers import MimeType, generateContentType
</span><span class="cx"> from txweb2.stream import readStream
</span><span class="lines">@@ -86,8 +82,10 @@
</span><span class="cx"> from txdav.common.datastore.sql import CommonHome, CommonHomeChild, \
</span><span class="cx">     CommonObjectResource, ECALENDARTYPE
</span><span class="cx"> from txdav.common.datastore.sql_tables import _ATTACHMENTS_MODE_NONE, \
</span><del>-    _ATTACHMENTS_MODE_WRITE, schema, _BIND_MODE_OWN, \
-    _ATTACHMENTS_MODE_READ, _TRANSP_OPAQUE, _TRANSP_TRANSPARENT
</del><ins>+    _ATTACHMENTS_MODE_READ, _ATTACHMENTS_MODE_WRITE, _BIND_MODE_DIRECT, \
+    _BIND_MODE_GROUP, _BIND_MODE_GROUP_READ, _BIND_MODE_GROUP_WRITE, \
+    _BIND_MODE_OWN, _BIND_MODE_READ, _BIND_MODE_WRITE, _BIND_STATUS_ACCEPTED, \
+    _TRANSP_OPAQUE, _TRANSP_TRANSPARENT, schema
</ins><span class="cx"> from txdav.common.icommondatastore import IndexedSearchException, \
</span><span class="cx">     InternalDataStoreError, HomeChildNameAlreadyExistsError, \
</span><span class="cx">     HomeChildNameNotAllowedError, ObjectResourceTooBigError, \
</span><span class="lines">@@ -1753,6 +1751,357 @@
</span><span class="cx">         )
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+    #===============================================================================
+    # Group sharing
+    #===============================================================================
+    @inlineCallbacks
+    def reconcileGroupSharee(self, groupUID):
+        &quot;&quot;&quot;
+        reconcile bind table with group members
+        &quot;&quot;&quot;
+        changed = False
+        if (yield self.updateShareeGroupLink(groupUID)):
+            groupID = (yield self._txn.groupByUID(groupUID))[0]
+            memberUIDs = yield self._txn.groupMemberUIDs(groupID)
+            boundUIDs = set()
+
+            home = self._homeSchema
+            bind = self._bindSchema
+            rows = yield Select(
+                [home.OWNER_UID],
+                From=home,
+                Where=home.RESOURCE_ID.In(
+                    Select(
+                        [bind.HOME_RESOURCE_ID],
+                        From=bind,
+                        Where=(bind.CALENDAR_RESOURCE_ID == self._resourceID).And(
+                            (bind.BIND_MODE == _BIND_MODE_GROUP).Or(
+                             bind.BIND_MODE == _BIND_MODE_GROUP_READ).Or(
+                             bind.BIND_MODE == _BIND_MODE_GROUP_WRITE)
+                        )
+                    )
+                )
+            ).on(self._txn)
+            for [shareeHomeUID] in rows:
+                if shareeHomeUID in memberUIDs:
+                    boundUIDs.add(shareeHomeUID)
+                else:
+                    yield self.uninviteUIDFromShare(shareeHomeUID)
+                    changed = True
+
+            for memberUID in memberUIDs - boundUIDs:
+                shareeView = yield self.shareeView(memberUID)
+                newMode = _BIND_MODE_GROUP if shareeView is None else shareeView._groupModeAfterAddingOneGroupSharee()
+                if newMode is not None:
+                    yield super(Calendar, self).inviteUIDToShare(memberUID, newMode)
+                    changed = True
+
+        returnValue(changed)
+
+
+    def _groupModeAfterAddingOneIndividualSharee(self, mode):
+        &quot;&quot;&quot;
+        return bind mode after adding one individual sharee with mode
+        &quot;&quot;&quot;
+        addToGroupModeMap = {
+            _BIND_MODE_READ: _BIND_MODE_GROUP_READ,
+            _BIND_MODE_WRITE: _BIND_MODE_GROUP_WRITE,
+        }
+        return {
+            _BIND_MODE_GROUP_READ: addToGroupModeMap.get(mode),
+            _BIND_MODE_GROUP_WRITE: addToGroupModeMap.get(mode),
+            _BIND_MODE_GROUP: addToGroupModeMap.get(mode),
+        }.get(self._bindMode)
+
+
+    @inlineCallbacks
+    def _groupModeAfterRemovingOneIndividualSharee(self):
+        &quot;&quot;&quot;
+        return group mode after adding one group sharee or None
+        &quot;&quot;&quot;
+        if self._bindMode == _BIND_MODE_DIRECT:
+            gs = schema.GROUP_SHAREE
+            gm = schema.GROUP_MEMBERSHIP
+            rows = yield Select(
+                [Count(gs.GROUP_ID)],
+                From=gs,
+                 Where=(
+                    gs.GROUP_ID.In(
+                        Select(
+                            [gm.GROUP_ID],
+                            From=gm,
+                            Where=(
+                                gm.MEMBER_UID == Parameter(&quot;uid&quot;)
+                            )
+                        )
+                    )
+                )
+            ).on(self._txn, uid=self.viewerHome().uid())
+            groupMode = _BIND_MODE_GROUP if rows[0][0] &gt; 0 else None
+        else:
+            groupMode = {
+                _BIND_MODE_GROUP_READ: _BIND_MODE_GROUP,
+                _BIND_MODE_GROUP_WRITE: _BIND_MODE_GROUP,
+            }.get(self._bindMode)
+
+        returnValue(groupMode)
+
+
+    def _groupModeAfterAddingOneGroupSharee(self):
+        &quot;&quot;&quot;
+        return group mode after adding one group sharee or None
+        &quot;&quot;&quot;
+        return {
+            _BIND_MODE_GROUP: _BIND_MODE_GROUP,
+            _BIND_MODE_READ: _BIND_MODE_GROUP_READ,
+            _BIND_MODE_GROUP_READ: _BIND_MODE_GROUP_READ,
+            _BIND_MODE_WRITE: _BIND_MODE_GROUP_WRITE,
+            _BIND_MODE_GROUP_WRITE: _BIND_MODE_GROUP_WRITE,
+        }.get(self._bindMode)
+
+
+    @inlineCallbacks
+    def _groupModeAfterRemovingOneGroupSharee(self):
+        &quot;&quot;&quot;
+        return group mode after removing one group sharee or None
+        &quot;&quot;&quot;
+        # count group sharees that self is member of
+        gs = schema.GROUP_SHAREE
+        gm = schema.GROUP_MEMBERSHIP
+        rows = yield Select(
+            [Count(gs.GROUP_ID)],
+            From=gs,
+             Where=(
+                gs.GROUP_ID.In(
+                    Select(
+                        [gm.GROUP_ID],
+                        From=gm,
+                        Where=(
+                            gm.MEMBER_UID == Parameter(&quot;uid&quot;)
+                        )
+                    )
+                )
+            )
+        ).on(self._txn, uid=self.viewerHome().uid())
+        if rows[0][0] &gt; 0:
+            # no mode change for group shares
+            returnValue(
+                {
+                    _BIND_MODE_GROUP: _BIND_MODE_GROUP,
+                    _BIND_MODE_GROUP_READ: _BIND_MODE_GROUP_READ,
+                    _BIND_MODE_GROUP_WRITE: _BIND_MODE_GROUP_WRITE,
+                }.get(self._bindMode)
+            )
+
+        # else return mode without any groups
+        returnValue(
+            {
+                _BIND_MODE_GROUP_READ: _BIND_MODE_READ,
+                _BIND_MODE_GROUP_WRITE: _BIND_MODE_WRITE,
+            }.get(self._bindMode)
+        )
+
+
+    @inlineCallbacks
+    def updateShareeGroupLink(self, groupUID, mode=None):
+        &quot;&quot;&quot;
+        update schema.GROUP_SHAREE
+        &quot;&quot;&quot;
+        changed = False
+        (
+            groupID, _ignore_name, membershipHash, _ignore_modDate,
+            _ignore_extant
+        ) = yield self._txn.groupByUID(groupUID)
+
+        gs = schema.GROUP_SHAREE
+        rows = yield Select(
+            [gs.MEMBERSHIP_HASH, gs.GROUP_BIND_MODE],
+            From=gs,
+            Where=(gs.CALENDAR_ID == self._resourceID).And(
+                gs.GROUP_ID == groupID)
+        ).on(self._txn)
+        if rows:
+            [[gsMembershipHash, gsMode]] = rows
+            updateMap = {}
+            if gsMembershipHash != membershipHash:
+                updateMap[gs.MEMBERSHIP_HASH] = membershipHash
+            if mode is not None and gsMode != mode:
+                updateMap[gs.GROUP_BIND_MODE] = mode
+            if updateMap:
+                yield Update(
+                    updateMap,
+                    Where=(gs.CALENDAR_ID == self._resourceID).And(
+                        gs.GROUP_ID == groupID
+                    )
+                ).on(self._txn)
+                changed = True
+        else:
+            yield Insert({
+                gs.MEMBERSHIP_HASH: membershipHash,
+                gs.GROUP_BIND_MODE: mode,
+                gs.CALENDAR_ID: self._resourceID,
+                gs.GROUP_ID: groupID,
+            }).on(self._txn)
+            changed = True
+
+        returnValue(changed)
+
+
+    @inlineCallbacks
+    def effectiveShareMode(self):
+        if self._bindMode == _BIND_MODE_GROUP_WRITE:
+            returnValue(_BIND_MODE_WRITE)
+        elif self._bindMode in (_BIND_MODE_GROUP, _BIND_MODE_GROUP_READ):
+            gs = schema.GROUP_SHAREE
+            gm = schema.GROUP_MEMBERSHIP
+            rows = yield Select(
+                [Max(gs.GROUP_BIND_MODE)], # _BIND_MODE_WRITE &gt; _BIND_MODE_READ
+                From=gs,
+                 Where=(
+                    gs.GROUP_ID.In(
+                        Select(
+                            [gm.GROUP_ID],
+                            From=gm,
+                            Where=(
+                                gm.MEMBER_UID == Parameter(&quot;uid&quot;)
+                            )
+                        )
+                    )
+                )
+            ).on(self._txn, uid=self.viewerHome().uid())
+            returnValue(rows[0][0])
+        else:
+            returnValue(self._bindMode)
+
+
+    #
+    # Higher level API
+    #
+    @inlineCallbacks
+    def inviteUIDToShare(self, shareeUID, mode, summary=None, shareName=None):
+        &quot;&quot;&quot;
+        Invite a user to share this collection - either create the share if it does not exist, or
+        update the existing share with new values. Make sure a notification is sent as well.
+
+        @param shareeUID: UID of the sharee
+        @type shareeUID: C{str}
+        @param mode: access mode
+        @type mode: C{int}
+        @param summary: share message
+        @type summary: C{str}
+        &quot;&quot;&quot;
+
+        if not (
+                config.Sharing.Enabled and
+                config.Sharing.Calendars.Enabled and
+                config.Sharing.Calendars.Groups.Enabled
+        ):
+            returnValue((yield super(Calendar, self).inviteUIDToShare(shareeUID, mode, summary, shareName)))
+
+        record = yield self._txn.directoryService().recordWithUID(shareeUID.decode(&quot;utf-8&quot;))
+        if record is None:
+            returnValue((yield super(Calendar, self).inviteUIDToShare(shareeUID, mode, summary, shareName)))
+
+        if record.recordType != RecordType.group:
+            shareeView = yield self.shareeView(shareeUID)
+            groupMode = shareeView._groupModeAfterAddingOneIndividualSharee(mode) if shareeView else None
+            mode = mode if groupMode is None else groupMode
+            returnValue((yield super(Calendar, self).inviteUIDToShare(shareeUID, mode, summary, shareName)))
+
+        yield self.updateShareeGroupLink(shareeUID, mode=mode)
+
+        # invite every member of group
+        shareeViews = []
+        groupID = (yield self._txn.groupByUID(shareeUID))[0]
+        memberUIDs = yield self._txn.groupMemberUIDs(groupID)
+        for memberUID in memberUIDs:
+            if memberUID != self._home.uid():
+                shareeView = yield self.shareeView(memberUID)
+                newMode = _BIND_MODE_GROUP if shareeView is None else shareeView._groupModeAfterAddingOneGroupSharee()
+                if newMode is not None:
+                    # everything but direct
+                    shareeView = yield super(Calendar, self).inviteUIDToShare(memberUID, newMode, summary)
+                    shareeViews.append(shareeView)
+
+        # shared even if no sharees
+        yield self.setShared(True)
+
+        returnValue(tuple(shareeViews))
+
+
+    @inlineCallbacks
+    def directShareWithUser(self, shareeUID, shareName=None):
+        &quot;&quot;&quot;
+        Create a direct share with the specified user. Note it is currently up to the app layer
+        to enforce access control - this is not ideal as we really should have control of that in
+        the store. Once we do, this api will need to verify that access is allowed for a direct share.
+
+        NB no invitations are used with direct sharing.
+
+        @param shareeUID: UID of the sharee
+        @type shareeUID: C{str}
+        &quot;&quot;&quot;
+
+        shareeView = yield self.shareeView(shareeUID)
+        if shareeView is not None and shareeView._bindMode == _BIND_MODE_GROUP:
+            yield self.updateShare(shareeView, mode=_BIND_MODE_DIRECT, status=_BIND_STATUS_ACCEPTED)
+            returnValue(shareeView)
+        else:
+            returnValue((yield super(Calendar, self).directShareWithUser(shareeUID, shareName)))
+
+
+    @inlineCallbacks
+    def uninviteUIDFromShare(self, shareeUID):
+        &quot;&quot;&quot;
+        Remove a user or group from a share. Make sure a notification is sent as well.
+
+        @param shareeUID: UID of the sharee
+        @type shareeUID: C{str}
+        &quot;&quot;&quot;
+
+        # see if group sharee for self &amp; delete
+        gr = schema.GROUPS
+        gs = schema.GROUP_SHAREE
+        rows = yield Delete(
+            From=gs,
+            Where=(gs.CALENDAR_ID == self._resourceID).And(
+                gs.GROUP_ID == Select(
+                    [gr.GROUP_ID],
+                    From=gr,
+                    Where=(gr.GROUP_UID == shareeUID)
+                )
+            ),
+            Return=[gs.GROUP_ID]
+        ).on(self._txn)
+
+        if rows:
+            # uninvite each member of group
+            memberUIDs = yield self._txn.groupMemberUIDs(rows[0][0])
+            for memberUID in memberUIDs:
+                if memberUID != self._home.uid():
+                    shareeView = yield self.shareeView(memberUID)
+                    if shareeView is not None:
+                            newMode = yield shareeView._groupModeAfterRemovingOneGroupSharee()
+                            if newMode is None:
+                                if shareeView._bindMode != _BIND_MODE_DIRECT:
+                                    # one group or individual share: delete share
+                                    yield super(Calendar, self).uninviteUIDFromShare(memberUID)
+                            else:
+                                # multiple groups or group and individual was shared, update to new mode
+                                yield super(Calendar, self).inviteUIDToShare(memberUID, newMode)
+
+        else:
+            shareeView = yield self.shareeView(shareeUID)
+            if shareeView is not None:
+                newMode = yield shareeView._groupModeAfterRemovingOneIndividualSharee()
+                if newMode is None:
+                    # no group was shared, so delete share
+                    yield super(Calendar, self).uninviteUIDFromShare(shareeUID)
+                else:
+                    # multiple groups or group and individual was shared, update to new mode
+                    yield super(Calendar, self).inviteUIDToShare(shareeUID, newMode)
+
+
</ins><span class="cx"> icalfbtype_to_indexfbtype = {
</span><span class="cx">     &quot;UNKNOWN&quot;         : 0,
</span><span class="cx">     &quot;FREE&quot;            : 1,
</span><span class="lines">@@ -1954,14 +2303,16 @@
</span><span class="cx">         groupCUAToAttendeeMemberPropMap = {}
</span><span class="cx">         for groupCUA in groupCUAs:
</span><span class="cx"> 
</span><ins>+            groupCUAToAttendeeMemberPropMap[groupCUA] = ()
</ins><span class="cx">             groupRecord = yield self.directoryService().recordWithCalendarUserAddress(groupCUA)
</span><span class="cx">             if groupRecord:
</span><del>-                members = yield groupRecord.expandedMembers()
-                groupCUAToAttendeeMemberPropMap[groupRecord.canonicalCalendarUserAddress()] = tuple(
-                    [member.attendeeProperty(params={&quot;MEMBER&quot;: groupCUA}) for member in sorted(members, key=lambda x: x.uid)]
-                )
-            else:
-                groupCUAToAttendeeMemberPropMap[groupCUA] = ()
</del><ins>+                # get members
+                groupID = (yield self._txn.groupByUID(groupRecord.uid))[0]
+                if groupID is not None:
+                    members = yield self._txn.groupMembers(groupID)
+                    groupCUAToAttendeeMemberPropMap[groupRecord.canonicalCalendarUserAddress()] = tuple(
+                        [member.attendeeProperty(params={&quot;MEMBER&quot;: groupCUA}) for member in sorted(members, key=lambda x: x.uid)]
+                    )
</ins><span class="cx"> 
</span><span class="cx">         # sync group attendee members if inserting or group changed
</span><span class="cx">         changed = False
</span><span class="lines">@@ -2085,10 +2436,9 @@
</span><span class="cx">                 else:
</span><span class="cx">                     # delete existing group rows
</span><span class="cx">                     ga = schema.GROUP_ATTENDEE
</span><del>-                    rows = yield Delete(
</del><ins>+                    yield Delete(
</ins><span class="cx">                         From=ga,
</span><span class="cx">                         Where=ga.RESOURCE_ID == self._resourceID,
</span><del>-                        #Return=[ga.GROUP_ID]
</del><span class="cx">                     ).on(txn)
</span><span class="cx"> 
</span><span class="cx">         returnValue(isOldEventWithGroupAttendees)
</span></span></pre></div>
<a id="CalendarServertrunktxdavcaldavdatastoretesttest_sql_externalpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/caldav/datastore/test/test_sql_external.py (13774 => 13775)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/caldav/datastore/test/test_sql_external.py        2014-07-17 19:55:36 UTC (rev 13774)
+++ CalendarServer/trunk/txdav/caldav/datastore/test/test_sql_external.py        2014-07-17 21:54:34 UTC (rev 13775)
</span><span class="lines">@@ -108,7 +108,7 @@
</span><span class="cx">         self.assertEqual(len(invites), 0)
</span><span class="cx">         self.assertFalse(calendar.isShared())
</span><span class="cx"> 
</span><del>-        shareeView = yield calendar.inviteUserToShare(&quot;puser02&quot;, _BIND_MODE_READ, &quot;summary&quot;)
</del><ins>+        shareeView = yield calendar.inviteUIDToShare(&quot;puser02&quot;, _BIND_MODE_READ, &quot;summary&quot;)
</ins><span class="cx">         invites = yield calendar.sharingInvites()
</span><span class="cx">         self.assertEqual(len(invites), 1)
</span><span class="cx">         self.assertEqual(invites[0].uid, shareeView.shareUID())
</span><span class="lines">@@ -138,7 +138,7 @@
</span><span class="cx">         invites = yield calendar.sharingInvites()
</span><span class="cx">         self.assertEqual(len(invites), 1)
</span><span class="cx"> 
</span><del>-        yield calendar.uninviteUserFromShare(&quot;puser02&quot;)
</del><ins>+        yield calendar.uninviteUIDFromShare(&quot;puser02&quot;)
</ins><span class="cx">         invites = yield calendar.sharingInvites()
</span><span class="cx">         self.assertEqual(len(invites), 0)
</span><span class="cx"> 
</span><span class="lines">@@ -169,7 +169,7 @@
</span><span class="cx">         self.assertEqual(len(invites), 0)
</span><span class="cx">         self.assertFalse(calendar.isShared())
</span><span class="cx"> 
</span><del>-        shareeView = yield calendar.inviteUserToShare(&quot;puser02&quot;, _BIND_MODE_READ, &quot;summary&quot;)
</del><ins>+        shareeView = yield calendar.inviteUIDToShare(&quot;puser02&quot;, _BIND_MODE_READ, &quot;summary&quot;)
</ins><span class="cx">         invites = yield calendar.sharingInvites()
</span><span class="cx">         self.assertEqual(len(invites), 1)
</span><span class="cx"> 
</span><span class="lines">@@ -235,7 +235,7 @@
</span><span class="cx">         self.assertEqual(len(invites), 0)
</span><span class="cx">         self.assertFalse(calendar.isShared())
</span><span class="cx"> 
</span><del>-        shareeView = yield calendar.inviteUserToShare(&quot;puser02&quot;, _BIND_MODE_READ, &quot;summary&quot;)
</del><ins>+        shareeView = yield calendar.inviteUIDToShare(&quot;puser02&quot;, _BIND_MODE_READ, &quot;summary&quot;)
</ins><span class="cx">         invites = yield calendar.sharingInvites()
</span><span class="cx">         self.assertEqual(len(invites), 1)
</span><span class="cx"> 
</span><span class="lines">@@ -303,7 +303,7 @@
</span><span class="cx">         self.assertEqual(len(invites), 0)
</span><span class="cx">         self.assertFalse(calendar.isShared())
</span><span class="cx"> 
</span><del>-        shareeView = yield calendar.inviteUserToShare(&quot;puser02&quot;, _BIND_MODE_READ, &quot;summary&quot;)
</del><ins>+        shareeView = yield calendar.inviteUIDToShare(&quot;puser02&quot;, _BIND_MODE_READ, &quot;summary&quot;)
</ins><span class="cx">         invites = yield calendar.sharingInvites()
</span><span class="cx">         self.assertEqual(len(invites), 1)
</span><span class="cx">         inviteUID = shareeView.shareUID()
</span><span class="lines">@@ -370,7 +370,7 @@
</span><span class="cx">         invites = yield calendar.sharingInvites()
</span><span class="cx">         self.assertEqual(len(invites), 0)
</span><span class="cx"> 
</span><del>-        shareeView = yield calendar.inviteUserToShare(&quot;puser02&quot;, _BIND_MODE_READ, &quot;summary&quot;)
</del><ins>+        shareeView = yield calendar.inviteUIDToShare(&quot;puser02&quot;, _BIND_MODE_READ, &quot;summary&quot;)
</ins><span class="cx">         invites = yield calendar.sharingInvites()
</span><span class="cx">         self.assertEqual(len(invites), 1)
</span><span class="cx"> 
</span><span class="lines">@@ -598,7 +598,7 @@
</span><span class="cx">         invites = yield calendar.sharingInvites()
</span><span class="cx">         self.assertEqual(len(invites), 0)
</span><span class="cx"> 
</span><del>-        shareeView = yield calendar.inviteUserToShare(&quot;puser02&quot;, _BIND_MODE_READ, &quot;summary&quot;)
</del><ins>+        shareeView = yield calendar.inviteUIDToShare(&quot;puser02&quot;, _BIND_MODE_READ, &quot;summary&quot;)
</ins><span class="cx">         newCalName = shareeView.shareUID()
</span><span class="cx">         yield self.commit()
</span><span class="cx"> 
</span></span></pre></div>
<a id="CalendarServertrunktxdavcaldavdatastoretesttest_sql_sharingpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/caldav/datastore/test/test_sql_sharing.py (13774 => 13775)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/caldav/datastore/test/test_sql_sharing.py        2014-07-17 19:55:36 UTC (rev 13774)
+++ CalendarServer/trunk/txdav/caldav/datastore/test/test_sql_sharing.py        2014-07-17 21:54:34 UTC (rev 13775)
</span><span class="lines">@@ -15,20 +15,27 @@
</span><span class="cx"> ##
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+from twext.python.clsprop import classproperty
+from twext.python.filepath import CachingFilePath as FilePath
</ins><span class="cx"> from twisted.internet.defer import inlineCallbacks, returnValue
</span><span class="cx"> from twisted.trial.unittest import TestCase
</span><del>-
-from twext.python.clsprop import classproperty
-from txdav.common.datastore.test.util import CommonCommonTests, \
-    populateCalendarsFrom
-from txdav.common.datastore.sql_tables import _BIND_MODE_READ, \
-    _BIND_STATUS_INVITED, _BIND_MODE_DIRECT, _BIND_STATUS_ACCEPTED
</del><ins>+from twistedcaldav import customxml
+from twistedcaldav.stdconfig import config
</ins><span class="cx"> from txdav.base.propertystore.base import PropertyName
</span><ins>+from txdav.common.datastore.sql_tables import _BIND_MODE_DIRECT
+from txdav.common.datastore.sql_tables import _BIND_MODE_GROUP
+from txdav.common.datastore.sql_tables import _BIND_MODE_GROUP_READ
+from txdav.common.datastore.sql_tables import _BIND_MODE_GROUP_WRITE
+from txdav.common.datastore.sql_tables import _BIND_MODE_READ
+from txdav.common.datastore.sql_tables import _BIND_MODE_WRITE
+from txdav.common.datastore.sql_tables import _BIND_STATUS_ACCEPTED
+from txdav.common.datastore.sql_tables import _BIND_STATUS_INVITED
+from txdav.common.datastore.test.util import CommonCommonTests
+from txdav.common.datastore.test.util import populateCalendarsFrom
</ins><span class="cx"> from txdav.xml.base import WebDAVTextElement
</span><del>-from twistedcaldav import customxml
</del><span class="cx"> from txdav.xml.element import registerElement, registerElementClass
</span><ins>+import os
</ins><span class="cx"> 
</span><del>-
</del><span class="cx"> class BaseSharingTests(CommonCommonTests, TestCase):
</span><span class="cx">     &quot;&quot;&quot;
</span><span class="cx">     Test store-based calendar sharing.
</span><span class="lines">@@ -100,7 +107,7 @@
</span><span class="cx">         invites = yield calendar.sharingInvites()
</span><span class="cx">         self.assertEqual(len(invites), 0)
</span><span class="cx"> 
</span><del>-        shareeView = yield calendar.inviteUserToShare(&quot;user02&quot;, _BIND_MODE_READ, &quot;summary&quot;)
</del><ins>+        shareeView = yield calendar.inviteUIDToShare(&quot;user02&quot;, _BIND_MODE_READ, &quot;summary&quot;)
</ins><span class="cx">         inviteUID = shareeView.shareUID()
</span><span class="cx">         yield self.commit()
</span><span class="cx"> 
</span><span class="lines">@@ -140,7 +147,7 @@
</span><span class="cx">         self.assertEqual(len(invites), 0)
</span><span class="cx">         self.assertFalse(calendar.isShared())
</span><span class="cx"> 
</span><del>-        shareeView = yield calendar.inviteUserToShare(&quot;user02&quot;, _BIND_MODE_READ, &quot;summary&quot;)
</del><ins>+        shareeView = yield calendar.inviteUIDToShare(&quot;user02&quot;, _BIND_MODE_READ, &quot;summary&quot;)
</ins><span class="cx">         invites = yield calendar.sharingInvites()
</span><span class="cx">         self.assertEqual(len(invites), 1)
</span><span class="cx">         self.assertEqual(invites[0].uid, shareeView.shareUID())
</span><span class="lines">@@ -168,7 +175,7 @@
</span><span class="cx">         invites = yield calendar.sharingInvites()
</span><span class="cx">         self.assertEqual(len(invites), 1)
</span><span class="cx"> 
</span><del>-        yield calendar.uninviteUserFromShare(&quot;user02&quot;)
</del><ins>+        yield calendar.uninviteUIDFromShare(&quot;user02&quot;)
</ins><span class="cx">         invites = yield calendar.sharingInvites()
</span><span class="cx">         self.assertEqual(len(invites), 0)
</span><span class="cx"> 
</span><span class="lines">@@ -198,7 +205,7 @@
</span><span class="cx">         self.assertEqual(len(invites), 0)
</span><span class="cx">         self.assertFalse(calendar.isShared())
</span><span class="cx"> 
</span><del>-        shareeView = yield calendar.inviteUserToShare(&quot;user02&quot;, _BIND_MODE_READ, &quot;summary&quot;)
</del><ins>+        shareeView = yield calendar.inviteUIDToShare(&quot;user02&quot;, _BIND_MODE_READ, &quot;summary&quot;)
</ins><span class="cx">         invites = yield calendar.sharingInvites()
</span><span class="cx">         self.assertEqual(len(invites), 1)
</span><span class="cx">         inviteUID = shareeView.shareUID()
</span><span class="lines">@@ -258,7 +265,7 @@
</span><span class="cx">         self.assertEqual(len(invites), 0)
</span><span class="cx">         self.assertFalse(calendar.isShared())
</span><span class="cx"> 
</span><del>-        shareeView = yield calendar.inviteUserToShare(&quot;user02&quot;, _BIND_MODE_READ, &quot;summary&quot;)
</del><ins>+        shareeView = yield calendar.inviteUIDToShare(&quot;user02&quot;, _BIND_MODE_READ, &quot;summary&quot;)
</ins><span class="cx">         invites = yield calendar.sharingInvites()
</span><span class="cx">         self.assertEqual(len(invites), 1)
</span><span class="cx">         inviteUID = shareeView.shareUID()
</span><span class="lines">@@ -319,7 +326,7 @@
</span><span class="cx">         self.assertEqual(len(invites), 0)
</span><span class="cx">         self.assertFalse(calendar.isShared())
</span><span class="cx"> 
</span><del>-        shareeView = yield calendar.inviteUserToShare(&quot;user02&quot;, _BIND_MODE_READ, &quot;summary&quot;)
</del><ins>+        shareeView = yield calendar.inviteUIDToShare(&quot;user02&quot;, _BIND_MODE_READ, &quot;summary&quot;)
</ins><span class="cx">         invites = yield calendar.sharingInvites()
</span><span class="cx">         self.assertEqual(len(invites), 1)
</span><span class="cx">         inviteUID = shareeView.shareUID()
</span><span class="lines">@@ -379,7 +386,7 @@
</span><span class="cx">         invites = yield calendar.sharingInvites()
</span><span class="cx">         self.assertEqual(len(invites), 0)
</span><span class="cx"> 
</span><del>-        shareeView = yield calendar.inviteUserToShare(&quot;user02&quot;, _BIND_MODE_READ, &quot;summary&quot;)
</del><ins>+        shareeView = yield calendar.inviteUIDToShare(&quot;user02&quot;, _BIND_MODE_READ, &quot;summary&quot;)
</ins><span class="cx">         invites = yield calendar.sharingInvites()
</span><span class="cx">         self.assertEqual(len(invites), 1)
</span><span class="cx">         inviteUID = shareeView.shareUID()
</span><span class="lines">@@ -581,6 +588,1149 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+class GroupSharingTests(BaseSharingTests):
+    &quot;&quot;&quot;
+    Test store-based group sharing.
+    &quot;&quot;&quot;
+
+    @inlineCallbacks
+    def setUp(self):
+        yield super(BaseSharingTests, self).setUp()
+
+        accountsFilePath = FilePath(
+            os.path.join(os.path.dirname(__file__), &quot;accounts&quot;)
+        )
+        yield self.buildStoreAndDirectory(
+            accounts=accountsFilePath.child(&quot;groupShareeAccounts.xml&quot;),
+            #resources=accountsFilePath.child(&quot;resources.xml&quot;),
+        )
+        yield self.populate()
+
+        self.paths = {}
+
+
+    def configure(self):
+        super(GroupSharingTests, 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 _check_notifications(self, uid, items):
+        notifyHome = yield self.transactionUnderTest().notificationsWithUID(uid)
+        notifications = yield notifyHome.listNotificationObjects()
+        self.assertEqual(set(notifications), set(items))
+
+
+
+class GroupSharing(GroupSharingTests):
+
+    @inlineCallbacks
+    def test_no_shares(self):
+        &quot;&quot;&quot;
+        Test that initially there are no shares.
+        &quot;&quot;&quot;
+
+        calendar = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        invites = yield calendar.sharingInvites()
+        self.assertEqual(len(invites), 0)
+
+
+    @inlineCallbacks
+    def test_invite_owner_group(self):
+        &quot;&quot;&quot;
+        Test that inviting group with just owner creates no shares.
+        &quot;&quot;&quot;
+
+        yield self._check_notifications(&quot;user01&quot;, [])
+
+        # Invite
+        calendar = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        invites = yield calendar.sharingInvites()
+        self.assertEqual(len(invites), 0)
+        self.assertFalse(calendar.isShared())
+
+        yield self._check_notifications(&quot;user01&quot;, [])
+        shareeViews = yield calendar.inviteUIDToShare(&quot;group01&quot;, _BIND_MODE_READ, &quot;summary&quot;)
+        self.assertEqual(len(shareeViews), 0)
+        invites = yield calendar.sharingInvites()
+        self.assertEqual(len(invites), 0)
+
+        self.assertTrue(calendar.isShared())
+
+        yield self.commit()
+
+        # Uninvite
+        calendar = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        yield calendar.uninviteUIDFromShare(&quot;group01&quot;)
+        noinvites = yield calendar.sharingInvites()
+        self.assertEqual(len(noinvites), 0)
+
+        yield self.commit()
+
+        yield self._check_notifications(&quot;user01&quot;, [])
+
+        calendar = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        self.assertTrue(calendar.isShared())
+        yield calendar.setShared(False)
+        self.assertFalse(calendar.isShared())
+
+
+    @inlineCallbacks
+    def test_invite_group(self):
+        &quot;&quot;&quot;
+        Test invite/uninvite group creates/removes shares and notifications.
+        &quot;&quot;&quot;
+
+        # Invite
+        calendar = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        invites = yield calendar.sharingInvites()
+        self.assertEqual(len(invites), 0)
+        self.assertFalse(calendar.isShared())
+
+        shareeViews = yield calendar.inviteUIDToShare(&quot;group02&quot;, _BIND_MODE_READ, &quot;summary&quot;)
+        self.assertEqual(len(shareeViews), 3)
+        invites = yield calendar.sharingInvites()
+        self.assertEqual(len(invites), 3)
+        shareeViewsDict = dict([(shareeView.shareUID(), shareeView) for shareeView in shareeViews])
+        for invite in invites:
+            shareeView = shareeViewsDict[invite.uid]
+            self.assertEqual(invite.ownerUID, &quot;user01&quot;)
+            self.assertEqual(invite.shareeUID, shareeView.viewerHome().uid())
+            self.assertEqual(invite.mode, _BIND_MODE_GROUP)
+            self.assertEqual((yield shareeView.effectiveShareMode()), _BIND_MODE_READ)
+            self.assertEqual(invite.status, _BIND_STATUS_INVITED)
+            self.assertEqual(invite.summary, &quot;summary&quot;)
+            yield self._check_notifications(invite.shareeUID, [invite.uid, ])
+
+        self.assertTrue(calendar.isShared())
+
+        yield self.commit()
+
+        # Uninvite
+        calendar = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        invites = yield calendar.sharingInvites()
+        self.assertEqual(len(invites), 3)
+        self.assertTrue(calendar.isShared())
+
+        yield calendar.uninviteUIDFromShare(&quot;group02&quot;)
+        uninvites = yield calendar.sharingInvites()
+        self.assertEqual(len(uninvites), 0)
+        self.assertTrue(calendar.isShared())
+
+        for invite in invites:
+            yield self._check_notifications(invite.shareeUID, [])
+
+        yield self.commit()
+
+        calendar = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        self.assertTrue(calendar.isShared())
+        yield calendar.setShared(False)
+        self.assertFalse(calendar.isShared())
+
+
+    @inlineCallbacks
+    def test_accept_group(self):
+        &quot;&quot;&quot;
+        Test that shares created from group invite are accepted normally
+        &quot;&quot;&quot;
+
+        # Invite
+        calendar = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        invites = yield calendar.sharingInvites()
+        self.assertEqual(len(invites), 0)
+        self.assertFalse(calendar.isShared())
+
+        shareeViews = yield calendar.inviteUIDToShare(&quot;group02&quot;, _BIND_MODE_READ, &quot;summary&quot;)
+        self.assertEqual(len(shareeViews), 3)
+        invites = yield calendar.sharingInvites()
+        self.assertEqual(len(invites), 3)
+        shareeViewsDict = dict([(shareeView.shareUID(), shareeView) for shareeView in shareeViews])
+        for invite in invites:
+            shareeView = shareeViewsDict[invite.uid]
+            self.assertEqual(invite.ownerUID, &quot;user01&quot;)
+            self.assertEqual(invite.shareeUID, shareeView.viewerHome().uid())
+            self.assertEqual(invite.mode, _BIND_MODE_GROUP)
+            self.assertEqual((yield shareeView.effectiveShareMode()), _BIND_MODE_READ)
+            self.assertEqual(invite.status, _BIND_STATUS_INVITED)
+            self.assertEqual(invite.summary, &quot;summary&quot;)
+            yield self._check_notifications(invite.shareeUID, [invite.uid, ])
+
+        self.assertTrue(calendar.isShared())
+
+        yield self.commit()
+
+        # Accept
+        for invite in invites:
+            shareeHome = yield self.homeUnderTest(name=invite.shareeUID)
+            yield shareeHome.acceptShare(invite.uid)
+
+        yield self._check_notifications(&quot;user01&quot;, [invite.uid + &quot;-reply&quot; for invite in invites])
+
+        calendar = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        self.assertTrue(calendar.isShared())
+
+        yield self.commit()
+
+        # Re-accept
+        for invite in invites:
+            shareeHome = yield self.homeUnderTest(name=invite.shareeUID)
+            yield shareeHome.acceptShare(invite.uid)
+
+        yield self._check_notifications(&quot;user01&quot;, [invite.uid + &quot;-reply&quot; for invite in invites])
+
+        calendar = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        self.assertTrue(calendar.isShared())
+
+
+    @inlineCallbacks
+    def test_decline_group(self):
+        &quot;&quot;&quot;
+        Test that shared from group invite are declined normally.
+        &quot;&quot;&quot;
+
+        # Invite
+        calendar = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        invites = yield calendar.sharingInvites()
+        self.assertEqual(len(invites), 0)
+        self.assertFalse(calendar.isShared())
+
+        shareeViews = yield calendar.inviteUIDToShare(&quot;group02&quot;, _BIND_MODE_READ, &quot;summary&quot;)
+        self.assertEqual(len(shareeViews), 3)
+        invites = yield calendar.sharingInvites()
+        self.assertEqual(len(invites), 3)
+        shareeViewsDict = dict([(shareeView.shareUID(), shareeView) for shareeView in shareeViews])
+        for invite in invites:
+            shareeView = shareeViewsDict[invite.uid]
+            self.assertEqual(invite.ownerUID, &quot;user01&quot;)
+            self.assertEqual(invite.shareeUID, shareeView.viewerHome().uid())
+            self.assertEqual(invite.mode, _BIND_MODE_GROUP)
+            self.assertEqual((yield shareeView.effectiveShareMode()), _BIND_MODE_READ)
+            self.assertEqual(invite.status, _BIND_STATUS_INVITED)
+            self.assertEqual(invite.summary, &quot;summary&quot;)
+            yield self._check_notifications(invite.shareeUID, [invite.uid, ])
+
+        self.assertTrue(calendar.isShared())
+
+        yield self.commit()
+
+        # Decline
+        for invite in invites:
+            shareeHome = yield self.homeUnderTest(name=invite.shareeUID)
+            yield shareeHome.declineShare(invite.uid)
+
+        yield self._check_notifications(&quot;user01&quot;, [invite.uid + &quot;-reply&quot; for invite in invites])
+
+        calendar = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        self.assertTrue(calendar.isShared())
+
+        yield self.commit()
+
+        # Re-decline
+        for invite in invites:
+            shareeHome = yield self.homeUnderTest(name=invite.shareeUID)
+            yield shareeHome.declineShare(invite.uid)
+
+        yield self._check_notifications(&quot;user01&quot;, [invite.uid + &quot;-reply&quot; for invite in invites])
+
+        calendar = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        self.assertTrue(calendar.isShared())
+
+
+    @inlineCallbacks
+    def test_accept_decline_share(self):
+        &quot;&quot;&quot;
+        Test that shares from group invite are accepted and declined normally.
+        &quot;&quot;&quot;
+
+        # Invite
+        calendar = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        invites = yield calendar.sharingInvites()
+        self.assertEqual(len(invites), 0)
+        self.assertFalse(calendar.isShared())
+
+        shareeViews = yield calendar.inviteUIDToShare(&quot;group02&quot;, _BIND_MODE_READ, &quot;summary&quot;)
+        self.assertEqual(len(shareeViews), 3)
+        invites = yield calendar.sharingInvites()
+        self.assertEqual(len(invites), 3)
+        shareeViewsDict = dict([(shareeView.shareUID(), shareeView) for shareeView in shareeViews])
+        for invite in invites:
+            shareeView = shareeViewsDict[invite.uid]
+            self.assertEqual(invite.ownerUID, &quot;user01&quot;)
+            self.assertEqual(invite.shareeUID, shareeView.viewerHome().uid())
+            self.assertEqual(invite.mode, _BIND_MODE_GROUP)
+            self.assertEqual((yield shareeView.effectiveShareMode()), _BIND_MODE_READ)
+            self.assertEqual(invite.status, _BIND_STATUS_INVITED)
+            self.assertEqual(invite.summary, &quot;summary&quot;)
+            yield self._check_notifications(invite.shareeUID, [invite.uid, ])
+
+        self.assertTrue(calendar.isShared())
+
+        yield self.commit()
+
+        # Accept
+        for invite in invites:
+            shareeHome = yield self.homeUnderTest(name=invite.shareeUID)
+            yield shareeHome.acceptShare(invite.uid)
+
+        yield self._check_notifications(&quot;user01&quot;, [invite.uid + &quot;-reply&quot; for invite in invites])
+
+        calendar = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        self.assertTrue(calendar.isShared())
+
+        yield self.commit()
+
+        # Decline
+        for invite in invites:
+            shareeHome = yield self.homeUnderTest(name=invite.shareeUID)
+            yield shareeHome.declineShare(invite.uid)
+
+        yield self._check_notifications(&quot;user01&quot;, [invite.uid + &quot;-reply&quot; for invite in invites])
+
+        calendar = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        self.assertTrue(calendar.isShared())
+
+
+    @inlineCallbacks
+    def test_accept_remove_group(self):
+        &quot;&quot;&quot;
+        Test that shares from group invite are accepted then removed normally.
+        &quot;&quot;&quot;
+
+        # Invite
+        calendar = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        invites = yield calendar.sharingInvites()
+        self.assertEqual(len(invites), 0)
+        self.assertFalse(calendar.isShared())
+
+        shareeViews = yield calendar.inviteUIDToShare(&quot;group02&quot;, _BIND_MODE_READ, &quot;summary&quot;)
+        self.assertEqual(len(shareeViews), 3)
+        invites = yield calendar.sharingInvites()
+        self.assertEqual(len(invites), 3)
+        shareeViewsDict = dict([(shareeView.shareUID(), shareeView) for shareeView in shareeViews])
+        for invite in invites:
+            shareeView = shareeViewsDict[invite.uid]
+            self.assertEqual(invite.ownerUID, &quot;user01&quot;)
+            self.assertEqual(invite.shareeUID, shareeView.viewerHome().uid())
+            self.assertEqual(invite.mode, _BIND_MODE_GROUP)
+            self.assertEqual((yield shareeView.effectiveShareMode()), _BIND_MODE_READ)
+            self.assertEqual(invite.status, _BIND_STATUS_INVITED)
+            self.assertEqual(invite.summary, &quot;summary&quot;)
+            yield self._check_notifications(invite.shareeUID, [invite.uid, ])
+
+        self.assertTrue(calendar.isShared())
+
+        yield self.commit()
+
+        # Accept
+        for invite in invites:
+            shareeHome = yield self.homeUnderTest(name=invite.shareeUID)
+            yield shareeHome.acceptShare(invite.uid)
+
+        yield self._check_notifications(&quot;user01&quot;, [invite.uid + &quot;-reply&quot; for invite in invites])
+
+        calendar = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        self.assertTrue(calendar.isShared())
+
+        yield self.commit()
+
+        # Delete
+        for invite in invites:
+            shareeCalendar = yield self.calendarUnderTest(home=invite.shareeUID, name=invite.uid)
+            yield shareeCalendar.deleteShare()
+
+        yield self._check_notifications(&quot;user01&quot;, [invite.uid + &quot;-reply&quot; for invite in invites])
+
+        calendar = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        self.assertTrue(calendar.isShared())
+
+
+    @inlineCallbacks
+    def test_accept_uninvite_group(self):
+        &quot;&quot;&quot;
+        Test group invite then accepted shared can be group uninvited
+        &quot;&quot;&quot;
+
+        # Invite
+        calendar = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        invites = yield calendar.sharingInvites()
+        self.assertEqual(len(invites), 0)
+        self.assertFalse(calendar.isShared())
+
+        shareeViews = yield calendar.inviteUIDToShare(&quot;group02&quot;, _BIND_MODE_READ, &quot;summary&quot;)
+        self.assertEqual(len(shareeViews), 3)
+        invites = yield calendar.sharingInvites()
+        self.assertEqual(len(invites), 3)
+        shareeViewsDict = dict([(shareeView.shareUID(), shareeView) for shareeView in shareeViews])
+        for invite in invites:
+            shareeView = shareeViewsDict[invite.uid]
+            self.assertEqual(invite.ownerUID, &quot;user01&quot;)
+            self.assertEqual(invite.shareeUID, shareeView.viewerHome().uid())
+            self.assertEqual(invite.mode, _BIND_MODE_GROUP)
+            self.assertEqual((yield shareeView.effectiveShareMode()), _BIND_MODE_READ)
+            self.assertEqual(invite.status, _BIND_STATUS_INVITED)
+            self.assertEqual(invite.summary, &quot;summary&quot;)
+            yield self._check_notifications(invite.shareeUID, [invite.uid, ])
+
+        self.assertTrue(calendar.isShared())
+
+        yield self.commit()
+
+        # Accept
+        for invite in invites:
+            shareeHome = yield self.homeUnderTest(name=invite.shareeUID)
+            yield shareeHome.acceptShare(invite.uid)
+
+        yield self._check_notifications(&quot;user01&quot;, [invite.uid + &quot;-reply&quot; for invite in invites])
+
+        calendar = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        self.assertTrue(calendar.isShared())
+
+        yield self.commit()
+
+        # Uninvite
+        calendar = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        yield calendar.uninviteUIDFromShare(&quot;group02&quot;)
+        noinvites = yield calendar.sharingInvites()
+        self.assertEqual(len(noinvites), 0)
+
+        for invite in invites:
+            self.assertEqual((yield self.calendarUnderTest(home=invite.shareeUID, name=invite.uid)), None)
+
+        yield self.commit()
+
+        # no extra notifications
+        yield self._check_notifications(&quot;user01&quot;, [invite.uid + &quot;-reply&quot; for invite in invites])
+
+        calendar = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        self.assertTrue(calendar.isShared())
+
+
+    @inlineCallbacks
+    def test_accept_two_groups(self):
+        &quot;&quot;&quot;
+        Test invite/accept of two groups.
+        &quot;&quot;&quot;
+
+        # Invite
+        calendar = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        invites = yield calendar.sharingInvites()
+        self.assertEqual(len(invites), 0)
+        self.assertFalse(calendar.isShared())
+
+        shareeViewsGroup02 = yield calendar.inviteUIDToShare(&quot;group02&quot;, _BIND_MODE_WRITE, &quot;summary&quot;)
+        self.assertEqual(len(shareeViewsGroup02), 3)
+        shareeViewsGroup03 = yield calendar.inviteUIDToShare(&quot;group03&quot;, _BIND_MODE_READ, &quot;summary&quot;)
+        self.assertEqual(len(shareeViewsGroup03), 3)
+        shareeViewsDict = dict([(shareeView.shareUID(), shareeView) for shareeView in shareeViewsGroup02 + shareeViewsGroup03])
+        self.assertEqual(len(shareeViewsDict), 4)
+        invites = yield calendar.sharingInvites()
+        self.assertEqual(len(invites), 4)
+        for invite in invites:
+            shareeView = shareeViewsDict[invite.uid]
+            self.assertEqual(invite.ownerUID, &quot;user01&quot;)
+            self.assertEqual(invite.shareeUID, shareeView.viewerHome().uid())
+            self.assertEqual(invite.mode, _BIND_MODE_GROUP)
+            self.assertEqual((yield shareeView.effectiveShareMode()), _BIND_MODE_WRITE if shareeView in shareeViewsGroup02 else _BIND_MODE_READ)
+            self.assertEqual(invite.status, _BIND_STATUS_INVITED)
+            self.assertEqual(invite.summary, &quot;summary&quot;)
+            yield self._check_notifications(invite.shareeUID, [invite.uid, ])
+
+        yield self.commit()
+
+        # accept
+        for invite in invites:
+            shareeHome = yield self.homeUnderTest(name=invite.shareeUID)
+            yield shareeHome.acceptShare(invite.uid)
+
+        yield self._check_notifications(&quot;user01&quot;, [invite.uid + &quot;-reply&quot; for invite in invites])
+
+        calendar = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        self.assertTrue(calendar.isShared())
+
+        yield self.commit()
+
+
+    @inlineCallbacks
+    def test_accept_uninvite_two_groups(self):
+        &quot;&quot;&quot;
+        Test 2 group invite, accept, 2 group uninvite.
+        &quot;&quot;&quot;
+
+        # Invite
+        calendar = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        invites = yield calendar.sharingInvites()
+        self.assertEqual(len(invites), 0)
+        self.assertFalse(calendar.isShared())
+
+        shareeViewsGroup02 = yield calendar.inviteUIDToShare(&quot;group02&quot;, _BIND_MODE_READ, &quot;summary&quot;)
+        self.assertEqual(len(shareeViewsGroup02), 3)
+        shareeViewsGroup03 = yield calendar.inviteUIDToShare(&quot;group03&quot;, _BIND_MODE_READ, &quot;summary&quot;)
+        self.assertEqual(len(shareeViewsGroup03), 3)
+        shareeViewsDict = dict([(shareeView.shareUID(), shareeView) for shareeView in shareeViewsGroup02 + shareeViewsGroup03])
+        self.assertEqual(len(shareeViewsDict), 4)
+        invites = yield calendar.sharingInvites()
+        self.assertEqual(len(invites), 4)
+        for invite in invites:
+            shareeView = shareeViewsDict[invite.uid]
+            self.assertEqual(invite.ownerUID, &quot;user01&quot;)
+            self.assertEqual(invite.shareeUID, shareeView.viewerHome().uid())
+            self.assertEqual(invite.mode, _BIND_MODE_GROUP)
+            self.assertEqual((yield shareeView.effectiveShareMode()), _BIND_MODE_READ)
+            self.assertEqual(invite.status, _BIND_STATUS_INVITED)
+            self.assertEqual(invite.summary, &quot;summary&quot;)
+            yield self._check_notifications(invite.shareeUID, [invite.uid, ])
+
+        yield self.commit()
+
+        # accept
+        for invite in invites:
+            shareeHome = yield self.homeUnderTest(name=invite.shareeUID)
+            yield shareeHome.acceptShare(invite.uid)
+
+        yield self._check_notifications(&quot;user01&quot;, [invite.uid + &quot;-reply&quot; for invite in invites])
+
+        calendar = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        self.assertTrue(calendar.isShared())
+
+        yield self.commit()
+
+        # Uninvite one
+        calendar = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        yield calendar.uninviteUIDFromShare(&quot;group02&quot;)
+        invites = yield calendar.sharingInvites()
+        self.assertEqual(len(invites), 3)
+
+        for invite in invites:
+            shareeView = yield self.calendarUnderTest(home=invite.shareeUID, name=invite.uid)
+            self.assertNotEqual(shareeView, None)
+            self.assertEqual(invite.ownerUID, &quot;user01&quot;)
+            self.assertEqual(invite.mode, _BIND_MODE_GROUP)
+            self.assertEqual((yield shareeView.effectiveShareMode()), _BIND_MODE_READ)
+            self.assertEqual(invite.status, _BIND_STATUS_ACCEPTED)
+            self.assertEqual(invite.summary, &quot;summary&quot;)
+            yield self._check_notifications(invite.shareeUID, [invite.uid, ])
+
+        yield self.commit()
+
+        # Uninvite other
+        calendar = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        yield calendar.uninviteUIDFromShare(&quot;group03&quot;)
+        noinvites = yield calendar.sharingInvites()
+        self.assertEqual(len(noinvites), 0)
+
+        for invite in invites:
+            self.assertEqual((yield self.calendarUnderTest(home=invite.shareeUID, name=invite.uid)), None)
+
+
+    @inlineCallbacks
+    def test_accept_uninvite_two_groups_different_access(self):
+        &quot;&quot;&quot;
+        Test 2 group invite, accept, 2 group uninvite when group have different
+        access.
+        &quot;&quot;&quot;
+
+        # Invite
+        calendar = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        invites = yield calendar.sharingInvites()
+        self.assertEqual(len(invites), 0)
+        self.assertFalse(calendar.isShared())
+
+        shareeViewsGroup02 = yield calendar.inviteUIDToShare(&quot;group02&quot;, _BIND_MODE_WRITE, &quot;summary&quot;)
+        self.assertEqual(len(shareeViewsGroup02), 3)
+        shareeViewsGroup03 = yield calendar.inviteUIDToShare(&quot;group03&quot;, _BIND_MODE_READ, &quot;summary&quot;)
+        self.assertEqual(len(shareeViewsGroup03), 3)
+        shareeViewsDict = dict([(shareeView.shareUID(), shareeView) for shareeView in shareeViewsGroup02 + shareeViewsGroup03])
+        self.assertEqual(len(shareeViewsDict), 4)
+        invites = yield calendar.sharingInvites()
+        self.assertEqual(len(invites), 4)
+        for invite in invites:
+            shareeView = shareeViewsDict[invite.uid]
+            self.assertEqual(invite.ownerUID, &quot;user01&quot;)
+            self.assertEqual(invite.shareeUID, shareeView.viewerHome().uid())
+            self.assertEqual(invite.mode, _BIND_MODE_GROUP)
+            self.assertEqual((yield shareeView.effectiveShareMode()), _BIND_MODE_WRITE if shareeView in shareeViewsGroup02 else _BIND_MODE_READ)
+            self.assertEqual(invite.status, _BIND_STATUS_INVITED)
+            self.assertEqual(invite.summary, &quot;summary&quot;)
+            yield self._check_notifications(invite.shareeUID, [invite.uid, ])
+
+        yield self.commit()
+
+        # accept
+        for invite in invites:
+            shareeHome = yield self.homeUnderTest(name=invite.shareeUID)
+            yield shareeHome.acceptShare(invite.uid)
+
+        yield self._check_notifications(&quot;user01&quot;, [invite.uid + &quot;-reply&quot; for invite in invites])
+
+        calendar = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        self.assertTrue(calendar.isShared())
+
+        yield self.commit()
+
+        # Uninvite one
+        calendar = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        yield calendar.uninviteUIDFromShare(&quot;group02&quot;)
+        invites = yield calendar.sharingInvites()
+        self.assertEqual(len(invites), 3)
+
+        for invite in invites:
+            shareeView = yield self.calendarUnderTest(home=invite.shareeUID, name=invite.uid)
+            self.assertNotEqual(shareeView, None)
+            self.assertEqual(invite.ownerUID, &quot;user01&quot;)
+            self.assertEqual(invite.mode, _BIND_MODE_GROUP)
+            self.assertEqual((yield shareeView.effectiveShareMode()), _BIND_MODE_READ)
+            self.assertEqual(invite.status, _BIND_STATUS_ACCEPTED)
+            self.assertEqual(invite.summary, &quot;summary&quot;)
+            yield self._check_notifications(invite.shareeUID, [invite.uid, ])
+
+        yield self.commit()
+
+        # Uninvite other
+        calendar = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        yield calendar.uninviteUIDFromShare(&quot;group03&quot;)
+        noinvites = yield calendar.sharingInvites()
+        self.assertEqual(len(noinvites), 0)
+
+        for invite in invites:
+            self.assertEqual((yield self.calendarUnderTest(home=invite.shareeUID, name=invite.uid)), None)
+
+
+
+class MixedSharing(GroupSharingTests):
+    &quot;&quot;&quot;
+    Test store-based combined individual and group sharing.
+    &quot;&quot;&quot;
+
+    @inlineCallbacks
+    def test_accept_uninvite_individual_and_group(self):
+        &quot;&quot;&quot;
+        Test individual invite + group containing individual invite, accept,
+        then uninvite individual, group.
+        &quot;&quot;&quot;
+
+        # Invite
+        calendar = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        invites = yield calendar.sharingInvites()
+        self.assertEqual(len(invites), 0)
+        self.assertFalse(calendar.isShared())
+
+        shareeViewUser07 = yield calendar.inviteUIDToShare(&quot;user07&quot;, _BIND_MODE_READ, &quot;summary&quot;)
+        self.assertNotEqual(shareeViewUser07, None)
+        shareeViewsGroup02 = yield calendar.inviteUIDToShare(&quot;group02&quot;, _BIND_MODE_READ, &quot;summary&quot;)
+        self.assertEqual(len(shareeViewsGroup02), 3)
+
+        shareeViewsDict = dict([(shareeView.shareUID(), shareeView) for shareeView in shareeViewsGroup02 + (shareeViewUser07,)])
+        self.assertEqual(len(shareeViewsDict), 3)
+        invites = yield calendar.sharingInvites()
+        self.assertEqual(len(invites), 3)
+        for invite in invites:
+            shareeView = shareeViewsDict[invite.uid]
+            self.assertEqual(invite.ownerUID, &quot;user01&quot;)
+            self.assertEqual(invite.shareeUID, shareeView.viewerHome().uid())
+            self.assertEqual(invite.mode, _BIND_MODE_GROUP_READ if invite.shareeUID == &quot;user07&quot; else _BIND_MODE_GROUP)
+            self.assertEqual((yield shareeView.effectiveShareMode()), _BIND_MODE_READ)
+            self.assertEqual(invite.status, _BIND_STATUS_INVITED)
+            self.assertEqual(invite.summary, &quot;summary&quot;)
+            yield self._check_notifications(invite.shareeUID, [invite.uid, ])
+
+        yield self.commit()
+
+        # accept
+        for invite in invites:
+            shareeHome = yield self.homeUnderTest(name=invite.shareeUID)
+            yield shareeHome.acceptShare(invite.uid)
+
+        yield self._check_notifications(&quot;user01&quot;, [invite.uid + &quot;-reply&quot; for invite in invites])
+
+        calendar = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        self.assertTrue(calendar.isShared())
+
+        yield self.commit()
+
+        # Uninvite individual
+        calendar = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        yield calendar.uninviteUIDFromShare(&quot;user07&quot;)
+        invites = yield calendar.sharingInvites()
+        self.assertEqual(len(invites), 3)
+        for invite in invites:
+            shareeView = yield calendar.shareeView(invite.shareeUID)
+            self.assertNotEqual(shareeView, None)
+            self.assertEqual(invite.uid, shareeView.shareName())
+            self.assertEqual(invite.ownerUID, &quot;user01&quot;)
+            self.assertEqual(invite.mode, _BIND_MODE_GROUP)
+            self.assertEqual((yield shareeView.effectiveShareMode()), _BIND_MODE_READ)
+            self.assertEqual(invite.status, _BIND_STATUS_ACCEPTED)
+            self.assertEqual(invite.summary, &quot;summary&quot;)
+            yield self._check_notifications(invite.shareeUID, [invite.uid, ])
+
+        # Uninvite group
+        calendar = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        yield calendar.uninviteUIDFromShare(&quot;group02&quot;)
+        noinvites = yield calendar.sharingInvites()
+        self.assertEqual(len(noinvites), 0)
+
+        for invite in invites:
+            self.assertEqual((yield self.calendarUnderTest(home=invite.shareeUID, name=invite.uid)), None)
+
+
+    @inlineCallbacks
+    def test_accept_uninvite_individual_direct_and_group(self):
+        &quot;&quot;&quot;
+        Test individual invite + group containing individual invite, accept,
+        then uninvite individual, group.
+        &quot;&quot;&quot;
+
+        # Invite
+        calendar = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        invites = yield calendar.sharingInvites()
+        self.assertEqual(len(invites), 0)
+        self.assertFalse(calendar.isShared())
+
+        shareeViewUser07 = yield calendar.directShareWithUser(&quot;user07&quot;)
+        self.assertNotEqual(shareeViewUser07, None)
+        invites = yield calendar.sharingInvites()
+        self.assertEqual(len(invites), 1)
+        self.assertEqual(invites[0].uid, shareeViewUser07.shareUID())
+        self.assertEqual(invites[0].ownerUID, &quot;user01&quot;)
+        self.assertEqual(invites[0].shareeUID, &quot;user07&quot;)
+        self.assertEqual(invites[0].mode, _BIND_MODE_DIRECT)
+        self.assertEqual(invites[0].status, _BIND_STATUS_ACCEPTED)
+
+        shareeViewsGroup02 = yield calendar.inviteUIDToShare(&quot;group02&quot;, _BIND_MODE_READ)
+        self.assertEqual(len(shareeViewsGroup02), 2)
+
+        shareeViewsDict = dict([(shareeView.shareUID(), shareeView) for shareeView in shareeViewsGroup02])
+        self.assertEqual(len(shareeViewsDict), 2)
+        invites = yield calendar.sharingInvites()
+        self.assertEqual(len(invites), 3)
+        for invite in invites:
+            shareeView = yield calendar.shareeView(invite.shareeUID)
+            self.assertEqual(invite.ownerUID, &quot;user01&quot;)
+            self.assertEqual(invite.shareeUID, shareeView.viewerHome().uid())
+            self.assertEqual(invite.mode, _BIND_MODE_DIRECT if invite.shareeUID == &quot;user07&quot; else _BIND_MODE_GROUP)
+            self.assertEqual((yield shareeView.effectiveShareMode()), _BIND_MODE_DIRECT if invite.shareeUID == &quot;user07&quot; else _BIND_MODE_READ)
+            self.assertEqual(invite.status, _BIND_STATUS_ACCEPTED if invite.shareeUID == &quot;user07&quot; else _BIND_STATUS_INVITED)
+            self.assertEqual(invite.summary, None)
+            yield self._check_notifications(invite.shareeUID, [] if invite.shareeUID == &quot;user07&quot; else [invite.uid, ])
+
+        yield self.commit()
+
+        # accept
+        for invite in invites:
+            if invite.shareeUID != &quot;user07&quot;:
+                shareeHome = yield self.homeUnderTest(name=invite.shareeUID)
+                yield shareeHome.acceptShare(invite.uid)
+
+        yield self._check_notifications(&quot;user01&quot;, [invite.uid + &quot;-reply&quot; for invite in invites if invite.shareeUID != &quot;user07&quot;])
+
+        calendar = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        self.assertTrue(calendar.isShared())
+
+        yield self.commit()
+
+        # Uninvite individual
+        calendar = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        yield calendar.uninviteUIDFromShare(&quot;user07&quot;)
+        invites = yield calendar.sharingInvites()
+        self.assertEqual(len(invites), 3)
+        for invite in invites:
+            shareeView = yield calendar.shareeView(invite.shareeUID)
+            self.assertNotEqual(shareeView, None)
+            self.assertEqual(invite.uid, shareeView.shareName())
+            self.assertEqual(invite.ownerUID, &quot;user01&quot;)
+            self.assertEqual(invite.mode, _BIND_MODE_GROUP)
+            self.assertEqual((yield shareeView.effectiveShareMode()), _BIND_MODE_READ)
+            self.assertEqual(invite.status, _BIND_STATUS_ACCEPTED)
+            self.assertEqual(invite.summary, None)
+            yield self._check_notifications(invite.shareeUID, [invite.uid, ])
+
+        # Uninvite group
+        calendar = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        yield calendar.uninviteUIDFromShare(&quot;group02&quot;)
+        noinvites = yield calendar.sharingInvites()
+        self.assertEqual(len(noinvites), 0)
+
+        for invite in invites:
+            self.assertEqual((yield self.calendarUnderTest(home=invite.shareeUID, name=invite.uid)), None)
+
+
+    @inlineCallbacks
+    def test_accept_uninvite_group_and_individual(self):
+        &quot;&quot;&quot;
+        Test group + individual contained in group invite, accept, then uninvite group, individual.
+        &quot;&quot;&quot;
+
+        # Invite
+        calendar = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        invites = yield calendar.sharingInvites()
+        self.assertEqual(len(invites), 0)
+        self.assertFalse(calendar.isShared())
+
+        shareeViewsGroup02 = yield calendar.inviteUIDToShare(&quot;group02&quot;, _BIND_MODE_READ, &quot;summary&quot;)
+        self.assertEqual(len(shareeViewsGroup02), 3)
+        shareeViewUser07 = yield calendar.inviteUIDToShare(&quot;user07&quot;, _BIND_MODE_READ, &quot;summary&quot;)
+        self.assertNotEqual(shareeViewUser07, None)
+
+        shareeViewsDict = dict([(shareeView.shareUID(), shareeView) for shareeView in shareeViewsGroup02 + (shareeViewUser07,)])
+        self.assertEqual(len(shareeViewsDict), 3)
+        invites = yield calendar.sharingInvites()
+        self.assertEqual(len(invites), 3)
+        for invite in invites:
+            shareeView = shareeViewsDict[invite.uid]
+            self.assertEqual(invite.uid, shareeView.shareUID())
+            self.assertEqual(invite.ownerUID, &quot;user01&quot;)
+            self.assertEqual(invite.shareeUID, shareeView.viewerHome().uid())
+            self.assertEqual(invite.mode, _BIND_MODE_GROUP_READ if invite.shareeUID == &quot;user07&quot; else _BIND_MODE_GROUP)
+            self.assertEqual((yield shareeView.effectiveShareMode()), _BIND_MODE_READ)
+            self.assertEqual(invite.status, _BIND_STATUS_INVITED)
+            self.assertEqual(invite.summary, &quot;summary&quot;)
+            yield self._check_notifications(invite.shareeUID, [invite.uid, ])
+
+        yield self.commit()
+
+        # accept
+        for invite in invites:
+            shareeHome = yield self.homeUnderTest(name=invite.shareeUID)
+            yield shareeHome.acceptShare(invite.uid)
+
+        yield self._check_notifications(&quot;user01&quot;, [invite.uid + &quot;-reply&quot; for invite in invites])
+
+        calendar = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        self.assertTrue(calendar.isShared())
+
+        yield self.commit()
+
+        # Uninvite group
+        calendar = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        yield calendar.uninviteUIDFromShare(&quot;group02&quot;)
+        invites = yield calendar.sharingInvites()
+        self.assertEqual(len(invites), 1)
+
+        for invite in invites:
+            shareeView = yield calendar.shareeView(invite.shareeUID)
+            self.assertNotEqual(shareeView, None)
+            self.assertEqual(invite.ownerUID, &quot;user01&quot;)
+            self.assertEqual(invite.uid, shareeView.shareName())
+            self.assertEqual(invite.mode, _BIND_MODE_READ)
+            self.assertEqual((yield shareeView.effectiveShareMode()), _BIND_MODE_READ)
+            self.assertEqual(invite.status, _BIND_STATUS_ACCEPTED)
+            self.assertEqual(invite.summary, &quot;summary&quot;)
+            yield self._check_notifications(invite.shareeUID, [invite.uid, ])
+
+        yield self.commit()
+
+        # Uninvite other
+        calendar = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        yield calendar.uninviteUIDFromShare(&quot;user07&quot;)
+        noinvites = yield calendar.sharingInvites()
+        self.assertEqual(len(noinvites), 0)
+
+        for invite in invites:
+            self.assertEqual((yield self.calendarUnderTest(home=invite.shareeUID, name=invite.uid)), None)
+
+
+    @inlineCallbacks
+    def test_accept_uninvite_group_and_individual_direct(self):
+        &quot;&quot;&quot;
+        Test group + individual contained in group invite, accept, then uninvite group, individual.
+        &quot;&quot;&quot;
+
+        # Invite
+        calendar = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        invites = yield calendar.sharingInvites()
+        self.assertEqual(len(invites), 0)
+        self.assertFalse(calendar.isShared())
+
+        shareeViewsGroup02 = yield calendar.inviteUIDToShare(&quot;group02&quot;, _BIND_MODE_READ)
+        self.assertEqual(len(shareeViewsGroup02), 3)
+        shareeViewsDict = dict([(shareeView.shareUID(), shareeView) for shareeView in shareeViewsGroup02])
+        self.assertEqual(len(shareeViewsDict), 3)
+        shareeViewUser07 = yield calendar.directShareWithUser(&quot;user07&quot;)
+        self.assertNotEqual(shareeViewUser07, None)
+
+        invites = yield calendar.sharingInvites()
+        self.assertEqual(len(invites), 3)
+        for invite in invites:
+            shareeView = yield calendar.shareeView(invite.shareeUID)
+            self.assertEqual(invite.ownerUID, &quot;user01&quot;)
+            self.assertEqual(invite.shareeUID, shareeView.viewerHome().uid())
+            self.assertEqual(invite.mode, _BIND_MODE_DIRECT if invite.shareeUID == &quot;user07&quot; else _BIND_MODE_GROUP)
+            self.assertEqual((yield shareeView.effectiveShareMode()), _BIND_MODE_DIRECT if invite.shareeUID == &quot;user07&quot; else _BIND_MODE_READ)
+            self.assertEqual(invite.status, _BIND_STATUS_ACCEPTED if invite.shareeUID == &quot;user07&quot; else _BIND_STATUS_INVITED)
+            self.assertEqual(invite.summary, None)
+            yield self._check_notifications(invite.shareeUID, [invite.uid, ])
+
+        yield self.commit()
+
+        # accept
+        for invite in invites:
+            if invite.shareeUID != &quot;user07&quot;:
+                shareeHome = yield self.homeUnderTest(name=invite.shareeUID)
+                yield shareeHome.acceptShare(invite.uid)
+
+        yield self._check_notifications(&quot;user01&quot;, [invite.uid + &quot;-reply&quot; for invite in invites if invite.shareeUID != &quot;user07&quot;])
+
+        calendar = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        self.assertTrue(calendar.isShared())
+
+        yield self.commit()
+
+        # Uninvite group
+        calendar = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        yield calendar.uninviteUIDFromShare(&quot;group02&quot;)
+        invites = yield calendar.sharingInvites()
+        self.assertEqual(len(invites), 1)
+
+        for invite in invites:
+            shareeView = yield calendar.shareeView(invite.shareeUID)
+            self.assertEqual(invites[0].ownerUID, &quot;user01&quot;)
+            self.assertNotEqual(shareeView, None)
+            self.assertEqual(invite.ownerUID, &quot;user01&quot;)
+            self.assertEqual(invite.uid, shareeView.shareName())
+            self.assertEqual(invite.mode, _BIND_MODE_DIRECT)
+            self.assertEqual((yield shareeView.effectiveShareMode()), _BIND_MODE_DIRECT)
+            self.assertEqual(invite.status, _BIND_STATUS_ACCEPTED)
+            self.assertEqual(invite.summary, None)
+            yield self._check_notifications(invite.shareeUID, [invite.uid, ])
+
+        yield self.commit()
+
+        # Uninvite individual
+        calendar = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        yield calendar.uninviteUIDFromShare(&quot;user07&quot;)
+        noinvites = yield calendar.sharingInvites()
+        self.assertEqual(len(noinvites), 0)
+
+        for invite in invites:
+            self.assertEqual((yield self.calendarUnderTest(home=invite.shareeUID, name=invite.uid)), None)
+
+
+    @inlineCallbacks
+    def test_accept_uninvite_individual_and_groups(self):
+        &quot;&quot;&quot;
+        Test individual invite + 2 group containing individual invite, accept, then uninvite individual, groups.
+        &quot;&quot;&quot;
+
+        # Invite
+        calendar = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        invites = yield calendar.sharingInvites()
+        self.assertEqual(len(invites), 0)
+        self.assertFalse(calendar.isShared())
+
+        shareeViewUser07 = yield calendar.inviteUIDToShare(&quot;user07&quot;, _BIND_MODE_READ, &quot;summary&quot;)
+        self.assertNotEqual(shareeViewUser07, None)
+        shareeViewsGroup02 = yield calendar.inviteUIDToShare(&quot;group02&quot;, _BIND_MODE_READ, &quot;summary&quot;)
+        self.assertEqual(len(shareeViewsGroup02), 3)
+        shareeViewsGroup03 = yield calendar.inviteUIDToShare(&quot;group03&quot;, _BIND_MODE_READ, &quot;summary&quot;)
+        self.assertEqual(len(shareeViewsGroup03), 3)
+
+        shareeViewsDict = dict([(shareeView.shareUID(), shareeView) for shareeView in shareeViewsGroup02 + (shareeViewUser07,) + shareeViewsGroup03])
+        self.assertEqual(len(shareeViewsDict), 4)
+        invites = yield calendar.sharingInvites()
+        self.assertEqual(len(invites), 4)
+        for invite in invites:
+            shareeView = shareeViewsDict[invite.uid]
+            self.assertEqual(invite.uid, shareeView.shareUID())
+            self.assertEqual(invite.ownerUID, &quot;user01&quot;)
+            self.assertEqual(invite.shareeUID, shareeView.viewerHome().uid())
+            self.assertEqual(invite.mode, _BIND_MODE_GROUP_READ if invite.shareeUID == &quot;user07&quot; else _BIND_MODE_GROUP)
+            self.assertEqual((yield shareeView.effectiveShareMode()), _BIND_MODE_READ)
+            self.assertEqual(invite.status, _BIND_STATUS_INVITED)
+            self.assertEqual(invite.summary, &quot;summary&quot;)
+            yield self._check_notifications(invite.shareeUID, [invite.uid, ])
+
+        yield self.commit()
+
+        # accept
+        for invite in invites:
+            shareeHome = yield self.homeUnderTest(name=invite.shareeUID)
+            yield shareeHome.acceptShare(invite.uid)
+
+        yield self._check_notifications(&quot;user01&quot;, [invite.uid + &quot;-reply&quot; for invite in invites])
+
+        calendar = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        self.assertTrue(calendar.isShared())
+
+        yield self.commit()
+
+        # Uninvite individual
+        calendar = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        yield calendar.uninviteUIDFromShare(&quot;user07&quot;)
+        invites = yield calendar.sharingInvites()
+        self.assertEqual(len(invites), 4)
+        for invite in invites:
+            shareeView = yield calendar.shareeView(invite.shareeUID)
+            self.assertNotEqual(shareeView, None)
+            self.assertEqual(invite.uid, shareeView.shareName())
+            self.assertEqual(invite.ownerUID, &quot;user01&quot;)
+            self.assertEqual(invite.mode, _BIND_MODE_GROUP)
+            self.assertEqual((yield shareeView.effectiveShareMode()), _BIND_MODE_READ)
+            self.assertEqual(invite.status, _BIND_STATUS_ACCEPTED)
+            self.assertEqual(invite.summary, &quot;summary&quot;)
+            yield self._check_notifications(invite.shareeUID, [invite.uid, ])
+
+        # Uninvite group
+        calendar = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        yield calendar.uninviteUIDFromShare(&quot;group02&quot;)
+        invites = yield calendar.sharingInvites()
+        self.assertEqual(len(invites), 3)
+
+        for invite in invites:
+            shareeView = yield calendar.shareeView(invite.shareeUID)
+            self.assertNotEqual(shareeView, None)
+            self.assertEqual(invite.ownerUID, &quot;user01&quot;)
+            self.assertEqual(invite.uid, shareeView.shareName())
+            self.assertEqual(invite.mode, _BIND_MODE_GROUP)
+            self.assertEqual((yield shareeView.effectiveShareMode()), _BIND_MODE_READ)
+            self.assertEqual(invite.status, _BIND_STATUS_ACCEPTED)
+            self.assertEqual(invite.summary, &quot;summary&quot;)
+            yield self._check_notifications(invite.shareeUID, [invite.uid, ])
+
+        # Uninvite group
+        calendar = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        yield calendar.uninviteUIDFromShare(&quot;group03&quot;)
+        noinvites = yield calendar.sharingInvites()
+        self.assertEqual(len(noinvites), 0)
+
+        for invite in invites:
+            self.assertEqual((yield self.calendarUnderTest(home=invite.shareeUID, name=invite.uid)), None)
+
+
+    @inlineCallbacks
+    def test_accept_uninvite_individual_and_groups_different_access(self):
+        &quot;&quot;&quot;
+        Test individual invite + 2 group containing individual invite, accept,
+        then uninvite individual, groups when individual and groups have
+        different access.
+        &quot;&quot;&quot;
+
+        # Invite
+        calendar = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        invites = yield calendar.sharingInvites()
+        self.assertEqual(len(invites), 0)
+        self.assertFalse(calendar.isShared())
+
+        shareeViewUser07 = yield calendar.inviteUIDToShare(&quot;user07&quot;, _BIND_MODE_WRITE)
+        self.assertNotEqual(shareeViewUser07, None)
+        shareeViewsGroup02 = yield calendar.inviteUIDToShare(&quot;group02&quot;, _BIND_MODE_READ)
+        self.assertEqual(len(shareeViewsGroup02), 3)
+        shareeViewsGroup03 = yield calendar.inviteUIDToShare(&quot;group03&quot;, _BIND_MODE_READ)
+        self.assertEqual(len(shareeViewsGroup03), 3)
+
+        shareeViewsDict = dict([(shareeView.shareUID(), shareeView) for shareeView in shareeViewsGroup02 + (shareeViewUser07,) + shareeViewsGroup03])
+        self.assertEqual(len(shareeViewsDict), 4)
+        invites = yield calendar.sharingInvites()
+        self.assertEqual(len(invites), 4)
+        for invite in invites:
+            shareeView = shareeViewsDict[invite.uid]
+            self.assertEqual(invite.uid, shareeView.shareUID())
+            self.assertEqual(invite.ownerUID, &quot;user01&quot;)
+            self.assertEqual(invite.shareeUID, shareeView.viewerHome().uid())
+            self.assertEqual(invite.mode, _BIND_MODE_GROUP_WRITE if invite.shareeUID == &quot;user07&quot; else _BIND_MODE_GROUP)
+            self.assertEqual((yield shareeView.effectiveShareMode()), _BIND_MODE_WRITE if invite.shareeUID == &quot;user07&quot; else _BIND_MODE_READ)
+            self.assertEqual(invite.status, _BIND_STATUS_INVITED)
+            self.assertEqual(invite.summary, None)
+            yield self._check_notifications(invite.shareeUID, [invite.uid, ])
+
+        yield self.commit()
+
+        # accept
+        for invite in invites:
+            shareeHome = yield self.homeUnderTest(name=invite.shareeUID)
+            yield shareeHome.acceptShare(invite.uid)
+
+        yield self._check_notifications(&quot;user01&quot;, [invite.uid + &quot;-reply&quot; for invite in invites])
+
+        calendar = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        self.assertTrue(calendar.isShared())
+
+        yield self.commit()
+
+        calendar = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        shareeViewUser07 = yield calendar.inviteUIDToShare(&quot;user07&quot;, _BIND_MODE_READ)
+        self.assertNotEqual(shareeViewUser07, None)
+        shareeViewsGroup02 = yield calendar.inviteUIDToShare(&quot;group02&quot;, _BIND_MODE_WRITE)
+        self.assertEqual(len(shareeViewsGroup02), 3)
+        invites = yield calendar.sharingInvites()
+        self.assertEqual(len(invites), 4)
+
+        for invite in invites:
+            shareeView = yield calendar.shareeView(invite.shareeUID)
+            self.assertNotEqual(shareeView, None)
+            self.assertEqual(invite.uid, shareeView.shareName())
+            self.assertEqual(invite.mode, _BIND_MODE_GROUP_READ if invite.shareeUID == &quot;user07&quot; else _BIND_MODE_GROUP)
+            self.assertEqual((yield shareeView.effectiveShareMode()), _BIND_MODE_WRITE if shareeView in shareeViewsGroup02 else _BIND_MODE_READ)
+            yield self._check_notifications(invite.shareeUID, [invite.uid, ])
+
+        yield self.commit()
+
+        calendar = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        shareeViewUser07 = yield calendar.inviteUIDToShare(&quot;user07&quot;, _BIND_MODE_WRITE)
+        self.assertNotEqual(shareeViewUser07, None)
+        shareeViewsGroup02 = yield calendar.inviteUIDToShare(&quot;group02&quot;, _BIND_MODE_READ)
+        self.assertEqual(len(shareeViewsGroup02), 3)
+        shareeViewsGroup03 = yield calendar.inviteUIDToShare(&quot;group03&quot;, _BIND_MODE_WRITE,)
+        self.assertEqual(len(shareeViewsGroup02), 3)
+        invites = yield calendar.sharingInvites()
+        self.assertEqual(len(invites), 4)
+
+        for invite in invites:
+            shareeView = yield calendar.shareeView(invite.shareeUID)
+            self.assertNotEqual(shareeView, None)
+            self.assertEqual(invite.uid, shareeView.shareName())
+            self.assertEqual(invite.mode, _BIND_MODE_GROUP_WRITE if invite.shareeUID == &quot;user07&quot; else _BIND_MODE_GROUP)
+            self.assertEqual((yield shareeView.effectiveShareMode()), _BIND_MODE_WRITE if shareeView in shareeViewsGroup03 else _BIND_MODE_READ)
+            yield self._check_notifications(invite.shareeUID, [invite.uid, ])
+
+        yield self.commit()
+
+        # Uninvite individual
+        calendar = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        yield calendar.uninviteUIDFromShare(&quot;user07&quot;)
+        invites = yield calendar.sharingInvites()
+        self.assertEqual(len(invites), 4)
+        for invite in invites:
+            shareeView = yield calendar.shareeView(invite.shareeUID)
+            self.assertNotEqual(shareeView, None)
+            self.assertEqual(invite.uid, shareeView.shareName())
+            self.assertEqual(invite.ownerUID, &quot;user01&quot;)
+            self.assertEqual(invite.mode, _BIND_MODE_GROUP)
+            self.assertEqual((yield shareeView.effectiveShareMode()), _BIND_MODE_READ if invite.shareeUID == &quot;user06&quot; else _BIND_MODE_WRITE)
+            self.assertEqual(invite.status, _BIND_STATUS_ACCEPTED)
+            self.assertEqual(invite.summary, None)
+            yield self._check_notifications(invite.shareeUID, [invite.uid, ])
+
+        # Uninvite group
+        calendar = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        yield calendar.uninviteUIDFromShare(&quot;group02&quot;)
+        invites = yield calendar.sharingInvites()
+        self.assertEqual(len(invites), 3)
+
+        for invite in invites:
+            shareeView = yield calendar.shareeView(invite.shareeUID)
+            self.assertNotEqual(shareeView, None)
+            self.assertEqual(invite.uid, shareeView.shareName())
+            self.assertEqual(invite.ownerUID, &quot;user01&quot;)
+            self.assertEqual(invite.mode, _BIND_MODE_GROUP)
+            self.assertEqual((yield shareeView.effectiveShareMode()), _BIND_MODE_WRITE)
+            self.assertEqual(invite.status, _BIND_STATUS_ACCEPTED)
+            self.assertEqual(invite.summary, None)
+            yield self._check_notifications(invite.shareeUID, [invite.uid, ])
+
+        # Uninvite group
+        calendar = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        yield calendar.uninviteUIDFromShare(&quot;group03&quot;)
+        noinvites = yield calendar.sharingInvites()
+        self.assertEqual(len(noinvites), 0)
+
+        for invite in invites:
+            self.assertEqual((yield self.calendarUnderTest(home=invite.shareeUID, name=invite.uid)), None)
+
+
+
</ins><span class="cx"> class SharingRevisions(BaseSharingTests):
</span><span class="cx">     &quot;&quot;&quot;
</span><span class="cx">     Test store-based sharing and interaction with revision table.
</span><span class="lines">@@ -609,7 +1759,7 @@
</span><span class="cx">         invites = yield calendar.sharingInvites()
</span><span class="cx">         self.assertEqual(len(invites), 0)
</span><span class="cx"> 
</span><del>-        shareeView = yield calendar.inviteUserToShare(&quot;user02&quot;, _BIND_MODE_READ, &quot;summary&quot;)
</del><ins>+        shareeView = yield calendar.inviteUIDToShare(&quot;user02&quot;, _BIND_MODE_READ, &quot;summary&quot;)
</ins><span class="cx">         newCalName = shareeView.shareUID()
</span><span class="cx">         yield self.commit()
</span><span class="cx"> 
</span></span></pre></div>
<a id="CalendarServertrunktxdavcaldavicalendarstorepy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/caldav/icalendarstore.py (13774 => 13775)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/caldav/icalendarstore.py        2014-07-17 19:55:36 UTC (rev 13774)
+++ CalendarServer/trunk/txdav/caldav/icalendarstore.py        2014-07-17 21:54:34 UTC (rev 13775)
</span><span class="lines">@@ -405,6 +405,18 @@
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         # TODO: implement this for the file store.
</span><span class="cx"> 
</span><ins>+    def effectiveShareMode(): #@NoSelf
+        &quot;&quot;&quot;
+        The effective sharing mode of this calendar after group sharing is
+        considered
+
+        @see: L{ICalendar.viewerCalendarHome}
+        @return: a L{Deferred} which fires with C{BIND_*} constant or L{None}
+        if the mode is unknown
+
+        @rtype: L{Deferred}
+        &quot;&quot;&quot;
+
</ins><span class="cx">     # FIXME: This should be calendarHome(), assuming we want to allow
</span><span class="cx">     # back-references.
</span><span class="cx">     def viewerCalendarHome(): #@NoSelf
</span></span></pre></div>
<a id="CalendarServertrunktxdavcarddavdatastoretesttest_sql_sharingpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/carddav/datastore/test/test_sql_sharing.py (13774 => 13775)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/carddav/datastore/test/test_sql_sharing.py        2014-07-17 19:55:36 UTC (rev 13774)
+++ CalendarServer/trunk/txdav/carddav/datastore/test/test_sql_sharing.py        2014-07-17 21:54:34 UTC (rev 13775)
</span><span class="lines">@@ -150,7 +150,7 @@
</span><span class="cx">         invites = yield addressbook.sharingInvites()
</span><span class="cx">         self.assertEqual(len(invites), 0)
</span><span class="cx"> 
</span><del>-        shareeView = yield addressbook.inviteUserToShare(&quot;user02&quot;, mode, &quot;summary&quot;)
</del><ins>+        shareeView = yield addressbook.inviteUIDToShare(&quot;user02&quot;, mode, &quot;summary&quot;)
</ins><span class="cx">         inviteUID = shareeView.shareUID()
</span><span class="cx">         yield self.commit()
</span><span class="cx"> 
</span><span class="lines">@@ -179,7 +179,7 @@
</span><span class="cx">     def _inviteGroupShare(self, groupname=&quot;group1.vcf&quot;, mode=_BIND_MODE_READ):
</span><span class="cx">         # Invite
</span><span class="cx">         group = yield self.addressbookObjectUnderTest(home=&quot;user01&quot;, addressbook_name=&quot;addressbook&quot;, name=groupname)
</span><del>-        shareeView = yield group.inviteUserToShare(&quot;user02&quot;, mode, &quot;summary&quot;)
</del><ins>+        shareeView = yield group.inviteUIDToShare(&quot;user02&quot;, mode, &quot;summary&quot;)
</ins><span class="cx">         inviteUID = shareeView.shareUID()
</span><span class="cx">         yield self.commit()
</span><span class="cx"> 
</span><span class="lines">@@ -264,7 +264,7 @@
</span><span class="cx">         self.assertEqual(len(invites), 0)
</span><span class="cx">         self.assertFalse(addressbook.isShared())
</span><span class="cx"> 
</span><del>-        shareeView = yield addressbook.inviteUserToShare(&quot;user02&quot;, _BIND_MODE_READ, &quot;summary&quot;)
</del><ins>+        shareeView = yield addressbook.inviteUIDToShare(&quot;user02&quot;, _BIND_MODE_READ, &quot;summary&quot;)
</ins><span class="cx">         invites = yield addressbook.sharingInvites()
</span><span class="cx">         self.assertEqual(len(invites), 1)
</span><span class="cx">         self.assertEqual(invites[0].uid, shareeView.shareUID())
</span><span class="lines">@@ -291,7 +291,7 @@
</span><span class="cx">         self.assertEqual(len(invites), 1)
</span><span class="cx">         self.assertTrue(addressbook.isShared())
</span><span class="cx"> 
</span><del>-        yield addressbook.uninviteUserFromShare(&quot;user02&quot;)
</del><ins>+        yield addressbook.uninviteUIDFromShare(&quot;user02&quot;)
</ins><span class="cx">         invites = yield addressbook.sharingInvites()
</span><span class="cx">         self.assertEqual(len(invites), 0)
</span><span class="cx"> 
</span><span class="lines">@@ -317,7 +317,7 @@
</span><span class="cx">         self.assertEqual(len(invites), 0)
</span><span class="cx">         self.assertFalse(addressbook.isShared())
</span><span class="cx"> 
</span><del>-        shareeView = yield addressbook.inviteUserToShare(&quot;user02&quot;, _BIND_MODE_READ, &quot;summary&quot;)
</del><ins>+        shareeView = yield addressbook.inviteUIDToShare(&quot;user02&quot;, _BIND_MODE_READ, &quot;summary&quot;)
</ins><span class="cx">         invites = yield addressbook.sharingInvites()
</span><span class="cx">         self.assertEqual(len(invites), 1)
</span><span class="cx">         inviteUID = shareeView.shareUID()
</span><span class="lines">@@ -373,7 +373,7 @@
</span><span class="cx">         self.assertEqual(len(invites), 0)
</span><span class="cx">         self.assertFalse(addressbook.isShared())
</span><span class="cx"> 
</span><del>-        shareeView = yield addressbook.inviteUserToShare(&quot;user02&quot;, _BIND_MODE_READ, &quot;summary&quot;)
</del><ins>+        shareeView = yield addressbook.inviteUIDToShare(&quot;user02&quot;, _BIND_MODE_READ, &quot;summary&quot;)
</ins><span class="cx">         invites = yield addressbook.sharingInvites()
</span><span class="cx">         self.assertEqual(len(invites), 1)
</span><span class="cx">         inviteUID = shareeView.shareUID()
</span><span class="lines">@@ -427,7 +427,7 @@
</span><span class="cx">         invites = yield addressbook.sharingInvites()
</span><span class="cx">         self.assertEqual(len(invites), 0)
</span><span class="cx"> 
</span><del>-        shareeView = yield addressbook.inviteUserToShare(&quot;user02&quot;, _BIND_MODE_READ, &quot;summary&quot;)
</del><ins>+        shareeView = yield addressbook.inviteUIDToShare(&quot;user02&quot;, _BIND_MODE_READ, &quot;summary&quot;)
</ins><span class="cx">         invites = yield addressbook.sharingInvites()
</span><span class="cx">         self.assertEqual(len(invites), 1)
</span><span class="cx">         inviteUID = shareeView.shareUID()
</span><span class="lines">@@ -474,7 +474,7 @@
</span><span class="cx">         invites = yield addressbook.sharingInvites()
</span><span class="cx">         self.assertEqual(len(invites), 0)
</span><span class="cx"> 
</span><del>-        shareeView = yield addressbook.inviteUserToShare(&quot;user02&quot;, _BIND_MODE_READ, &quot;summary&quot;)
</del><ins>+        shareeView = yield addressbook.inviteUIDToShare(&quot;user02&quot;, _BIND_MODE_READ, &quot;summary&quot;)
</ins><span class="cx">         invites = yield addressbook.sharingInvites()
</span><span class="cx">         self.assertEqual(len(invites), 1)
</span><span class="cx">         inviteUID = shareeView.shareUID()
</span><span class="lines">@@ -595,7 +595,7 @@
</span><span class="cx">         self.assertEqual(len(invites), 0)
</span><span class="cx">         self.assertFalse(group.isShared())
</span><span class="cx"> 
</span><del>-        shareeView = yield group.inviteUserToShare(&quot;user02&quot;, _BIND_MODE_READ, &quot;summary&quot;)
</del><ins>+        shareeView = yield group.inviteUIDToShare(&quot;user02&quot;, _BIND_MODE_READ, &quot;summary&quot;)
</ins><span class="cx">         invites = yield group.sharingInvites()
</span><span class="cx">         self.assertEqual(len(invites), 1)
</span><span class="cx">         self.assertEqual(invites[0].uid, shareeView.shareUID())
</span><span class="lines">@@ -626,7 +626,7 @@
</span><span class="cx">         self.assertEqual(len(invites), 1)
</span><span class="cx">         self.assertTrue(group.isShared())
</span><span class="cx"> 
</span><del>-        yield group.uninviteUserFromShare(&quot;user02&quot;)
</del><ins>+        yield group.uninviteUIDFromShare(&quot;user02&quot;)
</ins><span class="cx">         invites = yield group.sharingInvites()
</span><span class="cx">         self.assertEqual(len(invites), 0)
</span><span class="cx">         self.assertTrue(group.isShared())
</span><span class="lines">@@ -651,7 +651,7 @@
</span><span class="cx">         self.assertEqual(len(invites), 0)
</span><span class="cx">         self.assertFalse(group.isShared())
</span><span class="cx"> 
</span><del>-        shareeView = yield group.inviteUserToShare(&quot;user02&quot;, _BIND_MODE_READ, &quot;summary&quot;)
</del><ins>+        shareeView = yield group.inviteUIDToShare(&quot;user02&quot;, _BIND_MODE_READ, &quot;summary&quot;)
</ins><span class="cx">         invites = yield group.sharingInvites()
</span><span class="cx">         self.assertEqual(len(invites), 1)
</span><span class="cx">         inviteUID = shareeView.shareUID()
</span><span class="lines">@@ -700,7 +700,7 @@
</span><span class="cx">         self.assertEqual(len(invites), 0)
</span><span class="cx">         self.assertFalse(group.isShared())
</span><span class="cx"> 
</span><del>-        shareeView = yield group.inviteUserToShare(&quot;user02&quot;, _BIND_MODE_READ, &quot;summary&quot;)
</del><ins>+        shareeView = yield group.inviteUIDToShare(&quot;user02&quot;, _BIND_MODE_READ, &quot;summary&quot;)
</ins><span class="cx">         invites = yield group.sharingInvites()
</span><span class="cx">         self.assertEqual(len(invites), 1)
</span><span class="cx">         inviteUID = shareeView.shareUID()
</span><span class="lines">@@ -754,7 +754,7 @@
</span><span class="cx">         self.assertEqual(len(invites), 0)
</span><span class="cx">         self.assertFalse(group.isShared())
</span><span class="cx"> 
</span><del>-        shareeView = yield group.inviteUserToShare(&quot;user02&quot;, _BIND_MODE_READ, &quot;summary&quot;)
</del><ins>+        shareeView = yield group.inviteUIDToShare(&quot;user02&quot;, _BIND_MODE_READ, &quot;summary&quot;)
</ins><span class="cx">         invites = yield group.sharingInvites()
</span><span class="cx">         self.assertEqual(len(invites), 1)
</span><span class="cx">         inviteUID = shareeView.shareUID()
</span><span class="lines">@@ -805,7 +805,7 @@
</span><span class="cx">         invites = yield group.sharingInvites()
</span><span class="cx">         self.assertEqual(len(invites), 0)
</span><span class="cx"> 
</span><del>-        shareeView = yield group.inviteUserToShare(&quot;user02&quot;, _BIND_MODE_READ, &quot;summary&quot;)
</del><ins>+        shareeView = yield group.inviteUIDToShare(&quot;user02&quot;, _BIND_MODE_READ, &quot;summary&quot;)
</ins><span class="cx">         invites = yield group.sharingInvites()
</span><span class="cx">         self.assertEqual(len(invites), 1)
</span><span class="cx">         inviteUID = shareeView.shareUID()
</span><span class="lines">@@ -867,7 +867,7 @@
</span><span class="cx"> 
</span><span class="cx">         # Uninvite one
</span><span class="cx">         group = yield self.addressbookObjectUnderTest(home=&quot;user01&quot;, addressbook_name=&quot;addressbook&quot;, name=&quot;group1.vcf&quot;)
</span><del>-        yield group.uninviteUserFromShare(&quot;user02&quot;)
</del><ins>+        yield group.uninviteUIDFromShare(&quot;user02&quot;)
</ins><span class="cx">         invites = yield group.sharingInvites()
</span><span class="cx">         self.assertEqual(len(invites), 0)
</span><span class="cx"> 
</span><span class="lines">@@ -882,7 +882,7 @@
</span><span class="cx"> 
</span><span class="cx">         # Uninvite other
</span><span class="cx">         group = yield self.addressbookObjectUnderTest(home=&quot;user02&quot;, addressbook_name=&quot;user01&quot;, name=&quot;group2.vcf&quot;)
</span><del>-        yield group.uninviteUserFromShare(&quot;user02&quot;)
</del><ins>+        yield group.uninviteUIDFromShare(&quot;user02&quot;)
</ins><span class="cx">         invites = yield group.sharingInvites()
</span><span class="cx">         self.assertEqual(len(invites), 0)
</span><span class="cx"> 
</span><span class="lines">@@ -1002,7 +1002,7 @@
</span><span class="cx"> 
</span><span class="cx">         # Uninvite group1
</span><span class="cx">         group = yield self.addressbookObjectUnderTest(home=&quot;user01&quot;, addressbook_name=&quot;addressbook&quot;, name=&quot;group1.vcf&quot;)
</span><del>-        yield group.uninviteUserFromShare(&quot;user02&quot;)
</del><ins>+        yield group.uninviteUIDFromShare(&quot;user02&quot;)
</ins><span class="cx"> 
</span><span class="cx">         yield self._check_addressbook(&quot;user02&quot;, &quot;user01&quot;, self.fully_shared_children)
</span><span class="cx">         yield self._check_read_only(&quot;user02&quot;, &quot;user01&quot;, [&quot;group1.vcf&quot;, &quot;card2.vcf&quot;, ])
</span><span class="lines">@@ -1010,7 +1010,7 @@
</span><span class="cx"> 
</span><span class="cx">         # Uninvite group2
</span><span class="cx">         group = yield self.addressbookObjectUnderTest(home=&quot;user01&quot;, addressbook_name=&quot;addressbook&quot;, name=&quot;group2.vcf&quot;)
</span><del>-        yield group.uninviteUserFromShare(&quot;user02&quot;)
</del><ins>+        yield group.uninviteUIDFromShare(&quot;user02&quot;)
</ins><span class="cx"> 
</span><span class="cx">         yield self._check_addressbook(&quot;user02&quot;, &quot;user01&quot;, self.fully_shared_children)
</span><span class="cx">         yield self._check_read_only(&quot;user02&quot;, &quot;user01&quot;, self.all_children)
</span><span class="lines">@@ -1029,7 +1029,7 @@
</span><span class="cx"> 
</span><span class="cx">         # Add group1 read-write - but do not accept
</span><span class="cx">         group = yield self.addressbookObjectUnderTest(home=&quot;user01&quot;, addressbook_name=&quot;addressbook&quot;, name=&quot;group1.vcf&quot;)
</span><del>-        invited = yield group.inviteUserToShare(&quot;user02&quot;, _BIND_MODE_WRITE, &quot;summary&quot;)
</del><ins>+        invited = yield group.inviteUIDToShare(&quot;user02&quot;, _BIND_MODE_WRITE, &quot;summary&quot;)
</ins><span class="cx">         yield self._check_notifications(&quot;user02&quot;, [shareeName, invited.shareUID(), ])
</span><span class="cx"> 
</span><span class="cx">         yield self._check_addressbook(&quot;user02&quot;, &quot;user01&quot;, self.fully_shared_children)
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastorefilepy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/file.py (13774 => 13775)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/file.py        2014-07-17 19:55:36 UTC (rev 13774)
+++ CalendarServer/trunk/txdav/common/datastore/file.py        2014-07-17 21:54:34 UTC (rev 13775)
</span><span class="lines">@@ -1084,6 +1084,13 @@
</span><span class="cx">         return _BIND_MODE_OWN
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+    def effectiveShareMode(self):
+        &quot;&quot;&quot;
+        Stub implementation of L{ICalendar.effectiveShareMode}; always returns L{_BIND_MODE_OWN}.
+        &quot;&quot;&quot;
+        return _BIND_MODE_OWN
+
+
</ins><span class="cx">     def owned(self):
</span><span class="cx">         return self._owned
</span><span class="cx"> 
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastorepoddingtesttest_conduitpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/podding/test/test_conduit.py (13774 => 13775)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/podding/test/test_conduit.py        2014-07-17 19:55:36 UTC (rev 13774)
+++ CalendarServer/trunk/txdav/common/datastore/podding/test/test_conduit.py        2014-07-17 21:54:34 UTC (rev 13775)
</span><span class="lines">@@ -284,7 +284,7 @@
</span><span class="cx">         yield self.otherCommit()
</span><span class="cx"> 
</span><span class="cx">         calendar1 = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
</span><del>-        yield calendar1.uninviteUserFromShare(&quot;puser01&quot;)
</del><ins>+        yield calendar1.uninviteUIDFromShare(&quot;puser01&quot;)
</ins><span class="cx">         yield self.commit()
</span><span class="cx"> 
</span><span class="cx">         shared = yield self.calendarUnderTest(txn=self.newOtherTransaction(), home=&quot;puser01&quot;, name=&quot;shared-calendar&quot;)
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastorepoddingtestutilpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/podding/test/util.py (13774 => 13775)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/podding/test/util.py        2014-07-17 19:55:36 UTC (rev 13774)
+++ CalendarServer/trunk/txdav/common/datastore/podding/test/util.py        2014-07-17 21:54:34 UTC (rev 13775)
</span><span class="lines">@@ -193,7 +193,7 @@
</span><span class="cx"> 
</span><span class="cx">         home = yield self.homeUnderTest(name=ownerGUID, create=True)
</span><span class="cx">         calendar = yield home.calendarWithName(name)
</span><del>-        yield calendar.inviteUserToShare(shareeGUID, _BIND_MODE_WRITE, &quot;shared&quot;, shareName=&quot;shared-calendar&quot;)
</del><ins>+        yield calendar.inviteUIDToShare(shareeGUID, _BIND_MODE_WRITE, &quot;shared&quot;, shareName=&quot;shared-calendar&quot;)
</ins><span class="cx">         yield self.commit()
</span><span class="cx"> 
</span><span class="cx">         # ACK: home2 is None
</span><span class="lines">@@ -209,5 +209,5 @@
</span><span class="cx"> 
</span><span class="cx">         home = yield self.homeUnderTest(name=ownerGUID)
</span><span class="cx">         calendar = yield home.calendarWithName(name)
</span><del>-        yield calendar.uninviteUserFromShare(shareeGUID)
</del><ins>+        yield calendar.uninviteUIDFromShare(shareeGUID)
</ins><span class="cx">         yield self.commit()
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoresqlpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/sql.py (13774 => 13775)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/sql.py        2014-07-17 19:55:36 UTC (rev 13774)
+++ CalendarServer/trunk/txdav/common/datastore/sql.py        2014-07-17 21:54:34 UTC (rev 13775)
</span><span class="lines">@@ -61,12 +61,11 @@
</span><span class="cx"> from txdav.carddav.iaddressbookstore import IAddressBookTransaction
</span><span class="cx"> from txdav.common.datastore.common import HomeChildBase
</span><span class="cx"> from txdav.common.datastore.podding.conduit import PoddingConduit
</span><del>-from txdav.common.datastore.sql_tables import _BIND_MODE_OWN, \
-    _BIND_STATUS_ACCEPTED, _BIND_STATUS_DECLINED, _BIND_STATUS_INVALID, \
-    _BIND_STATUS_INVITED, _BIND_MODE_DIRECT, _BIND_STATUS_DELETED, \
-    _BIND_MODE_INDIRECT, _HOME_STATUS_NORMAL, _HOME_STATUS_EXTERNAL, \
-    _HOME_STATUS_PURGING
-from txdav.common.datastore.sql_tables import schema, splitSQLString
</del><ins>+from txdav.common.datastore.sql_tables import _BIND_MODE_DIRECT, \
+    _BIND_MODE_INDIRECT, _BIND_MODE_OWN, _BIND_STATUS_ACCEPTED, \
+    _BIND_STATUS_DECLINED, _BIND_STATUS_DELETED, _BIND_STATUS_INVALID, \
+    _BIND_STATUS_INVITED, _HOME_STATUS_EXTERNAL, _HOME_STATUS_NORMAL, \
+    _HOME_STATUS_PURGING, schema, splitSQLString
</ins><span class="cx"> from txdav.common.icommondatastore import ConcurrentModification, \
</span><span class="cx">     RecordNotAllowedError, ExternalShareFailed, ShareNotAllowed, \
</span><span class="cx">     IndexedSearchException, NotFoundError
</span><span class="lines">@@ -1069,20 +1068,27 @@
</span><span class="cx">         )
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+    @inlineCallbacks
</ins><span class="cx">     def addGroup(self, groupUID, name, membershipHash):
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         @type groupUID: C{unicode}
</span><span class="cx">         @type name: C{unicode}
</span><span class="cx">         @type membershipHash: C{str}
</span><span class="cx">         &quot;&quot;&quot;
</span><del>-        return self._addGroupQuery.on(
</del><ins>+        groupID = yield self._addGroupQuery.on(
</ins><span class="cx">             self,
</span><span class="cx">             name=name.encode(&quot;utf-8&quot;),
</span><span class="cx">             groupUID=groupUID.encode(&quot;utf-8&quot;),
</span><span class="cx">             membershipHash=membershipHash
</span><span class="cx">         )
</span><span class="cx"> 
</span><ins>+        record = yield self.directoryService().recordWithUID(groupUID)
+        yield self._refreshGroup(
+            groupUID, record, groupID, name.encode(&quot;utf-8&quot;), membershipHash
+        )
+        returnValue(groupID)
</ins><span class="cx"> 
</span><ins>+
</ins><span class="cx">     def updateGroup(self, groupUID, name, membershipHash, extant=True):
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         @type groupUID: C{unicode}
</span><span class="lines">@@ -1270,7 +1276,7 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><del>-    def membersOfGroup(self, groupID):
</del><ins>+    def groupMemberUIDs(self, groupID):
</ins><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         Returns the cached set of UIDs for members of the given groupID.
</span><span class="cx">         Sub-groups are not returned in the results but their members are,
</span><span class="lines">@@ -1290,8 +1296,133 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><del>-    def groupsFor(self, uid):
</del><ins>+    def refreshGroup(self, groupUID):
</ins><span class="cx">         &quot;&quot;&quot;
</span><ins>+        Refreshes the group membership cache.
+
+        @param groupUID: the group UID
+        @type groupUID: C{unicode}
+
+        @return: Deferred firing with tuple of group ID C{str}, and
+            membershipChanged C{boolean}
+
+        &quot;&quot;&quot;
+        log.debug(&quot;Faulting in group: {g}&quot;, g=groupUID)
+        record = (yield self.directoryService().recordWithUID(groupUID))
+        if record is None:
+            # the group has disappeared from the directory
+            log.info(&quot;Group is missing: {g}&quot;, g=groupUID)
+        else:
+            log.debug(&quot;Got group record: {u}&quot;, u=record.uid)
+
+        (
+            groupID, cachedName, cachedMembershipHash, _ignore_modified,
+            _ignore_extant
+        ) = yield self.groupByUID(
+            groupUID,
+            create=(record is not None)
+        )
+
+        membershipChanged = False
+        if groupID:
+            membershipChanged = yield self._refreshGroup(
+                groupUID, record, groupID, cachedName, cachedMembershipHash
+            )
+
+        returnValue((groupID, membershipChanged))
+
+
+    @inlineCallbacks
+    def _refreshGroup(self, groupUID, record, groupID, cachedName, cachedMembershipHash):
+        &quot;&quot;&quot;
+        @param groupUID: the directory record
+        @type groupUID: C{unicode}
+        @param record: the directory record
+        @type record: C{iDirectoryRecord}
+        @param groupID: group resource id
+        @type groupID: C{str}
+        @param cachedName: group name in the database
+        @type cachedName: C{unicode}
+        @param cachedMembershipHash: membership hash in the database
+        @type cachedMembershipHash: C{str}
+
+        @return: Deferred firing with membershipChanged C{boolean}
+
+        &quot;&quot;&quot;
+        if record is not None:
+            members = yield record.expandedMembers()
+            name = record.displayName
+            extant = True
+        else:
+            members = frozenset()
+            name = cachedName
+            extant = False
+
+        membershipHashContent = hashlib.md5()
+        members = list(members)
+        members.sort(key=lambda x: x.uid)
+        for member in members:
+            membershipHashContent.update(str(member.uid))
+        membershipHash = membershipHashContent.hexdigest()
+
+        if cachedMembershipHash != membershipHash:
+            membershipChanged = True
+            log.debug(
+                &quot;Group '{group}' changed&quot;, group=name
+            )
+        else:
+            membershipChanged = False
+
+        if membershipChanged or record is not None:
+            # also updates group mod date
+            yield self.updateGroup(
+                groupUID, name, membershipHash, extant=extant
+            )
+
+        if membershipChanged:
+            newMemberUIDs = set()
+            for member in members:
+                newMemberUIDs.add(member.uid)
+            yield self.synchronizeMembers(groupID, newMemberUIDs)
+
+        returnValue(membershipChanged)
+
+
+    @inlineCallbacks
+    def synchronizeMembers(self, groupID, newMemberUIDs):
+        numRemoved = numAdded = 0
+        cachedMemberUIDs = (yield self.groupMemberUIDs(groupID))
+
+        for memberUID in cachedMemberUIDs:
+            if memberUID not in newMemberUIDs:
+                numRemoved += 1
+                yield self.removeMemberFromGroup(memberUID, groupID)
+
+        for memberUID in newMemberUIDs:
+            if memberUID not in cachedMemberUIDs:
+                numAdded += 1
+                yield self.addMemberToGroup(memberUID, groupID)
+
+        returnValue((numAdded, numRemoved))
+
+
+    @inlineCallbacks
+    def groupMembers(self, groupID):
+        &quot;&quot;&quot;
+        The members of the given group as recorded in the db
+        &quot;&quot;&quot;
+        members = set()
+        memberUIDs = (yield self.groupMemberUIDs(groupID))
+        for uid in memberUIDs:
+            record = (yield self.directoryService().recordWithUID(uid))
+            if record is not None:
+                members.add(record)
+        returnValue(members)
+
+
+    @inlineCallbacks
+    def groupUIDsFor(self, uid):
+        &quot;&quot;&quot;
</ins><span class="cx">         Returns the cached set of UIDs for the groups this given uid is
</span><span class="cx">         a member of.
</span><span class="cx"> 
</span><span class="lines">@@ -2768,7 +2899,7 @@
</span><span class="cx">                 self.uid(), shareName=shareUID
</span><span class="cx">             )
</span><span class="cx">         else:
</span><del>-            shareeView = yield ownerView.inviteUserToShare(
</del><ins>+            shareeView = yield ownerView.inviteUIDToShare(
</ins><span class="cx">                 self.uid(), bindMode, summary, shareName=shareUID
</span><span class="cx">             )
</span><span class="cx"> 
</span><span class="lines">@@ -2792,7 +2923,7 @@
</span><span class="cx">             raise ExternalShareFailed(&quot;Invalid share ID: {}&quot;.format(shareUID))
</span><span class="cx"> 
</span><span class="cx">         # Now carry out the share operation
</span><del>-        yield ownerView.uninviteUserFromShare(self.uid())
</del><ins>+        yield ownerView.uninviteUIDFromShare(self.uid())
</ins><span class="cx"> 
</span><span class="cx">         # See if there are any references to the external share. If not,
</span><span class="cx">         # remove it
</span><span class="lines">@@ -4430,7 +4561,7 @@
</span><span class="cx">     # Higher level API
</span><span class="cx">     #
</span><span class="cx">     @inlineCallbacks
</span><del>-    def inviteUserToShare(self, shareeUID, mode, summary, shareName=None):
</del><ins>+    def inviteUIDToShare(self, shareeUID, mode, summary=None, shareName=None):
</ins><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         Invite a user to share this collection - either create the share if it does not exist, or
</span><span class="cx">         update the existing share with new values. Make sure a notification is sent as well.
</span><span class="lines">@@ -4487,7 +4618,7 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><del>-    def uninviteUserFromShare(self, shareeUID):
</del><ins>+    def uninviteUIDFromShare(self, shareeUID):
</ins><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         Remove a user from a share. Make sure a notification is sent as well.
</span><span class="cx"> 
</span><span class="lines">@@ -4570,7 +4701,7 @@
</span><span class="cx"> 
</span><span class="cx">         # Remove all sharees (direct and invited)
</span><span class="cx">         for invitation in (yield self.sharingInvites()):
</span><del>-            yield self.uninviteUserFromShare(invitation.shareeUID)
</del><ins>+            yield self.uninviteUIDFromShare(invitation.shareeUID)
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     def newShare(self, displayname=None):
</span><span class="lines">@@ -4599,7 +4730,6 @@
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         Called on the owner's resource.
</span><span class="cx">         &quot;&quot;&quot;
</span><del>-
</del><span class="cx">         # When deleting the message is the sharee's display name
</span><span class="cx">         displayname = shareeView.shareMessage()
</span><span class="cx">         if notificationState == _BIND_STATUS_DELETED:
</span><span class="lines">@@ -4617,7 +4747,7 @@
</span><span class="cx">             &quot;sharee&quot;: shareeView.viewerHome().uid(),
</span><span class="cx">             &quot;uid&quot;: shareeView.shareUID(),
</span><span class="cx">             &quot;status&quot;: shareeView.shareStatus() if notificationState is None else notificationState,
</span><del>-            &quot;access&quot;: shareeView.shareMode(),
</del><ins>+            &quot;access&quot;: (yield shareeView.effectiveShareMode()),
</ins><span class="cx">             &quot;ownerName&quot;: self.shareName(),
</span><span class="cx">             &quot;summary&quot;: displayname,
</span><span class="cx">         }
</span><span class="lines">@@ -4751,25 +4881,57 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><ins>+    def shareWithUID(self, shareeUID, mode, status=None, summary=None, shareName=None):
+        &quot;&quot;&quot;
+        Share this (owned) L{CommonHomeChild} with another principal.
+
+        @param shareeUID: The UID of the sharee.
+        @type: L{str}
+
+        @param mode: The sharing mode; L{_BIND_MODE_READ} or
+            L{_BIND_MODE_WRITE} or L{_BIND_MODE_DIRECT}
+        @type mode: L{str}
+
+        @param status: The sharing status; L{_BIND_STATUS_INVITED} or
+            L{_BIND_STATUS_ACCEPTED}
+        @type: L{str}
+
+        @param summary: The proposed message to go along with the share, which
+            will be used as the default display name.
+        @type: L{str}
+
+        @return: the name of the shared calendar in the new calendar home.
+        @rtype: L{str}
+        &quot;&quot;&quot;
+        shareeHome = yield self._txn.calendarHomeWithUID(shareeUID, create=True)
+        returnValue(
+            (yield self.shareWith(shareeHome, mode, status, summary, shareName))
+        )
+
+
+    @inlineCallbacks
</ins><span class="cx">     def shareWith(self, shareeHome, mode, status=None, summary=None, shareName=None):
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         Share this (owned) L{CommonHomeChild} with another home.
</span><span class="cx"> 
</span><span class="cx">         @param shareeHome: The home of the sharee.
</span><del>-        @type shareeHome: L{CommonHome}
</del><ins>+        @type: L{CommonHome}
</ins><span class="cx"> 
</span><span class="cx">         @param mode: The sharing mode; L{_BIND_MODE_READ} or
</span><span class="cx">             L{_BIND_MODE_WRITE} or L{_BIND_MODE_DIRECT}
</span><del>-        @type mode: L{str}
</del><ins>+        @type: L{str}
</ins><span class="cx"> 
</span><span class="cx">         @param status: The sharing status; L{_BIND_STATUS_INVITED} or
</span><span class="cx">             L{_BIND_STATUS_ACCEPTED}
</span><del>-        @type mode: L{str}
</del><ins>+        @type: L{str}
</ins><span class="cx"> 
</span><span class="cx">         @param summary: The proposed message to go along with the share, which
</span><span class="cx">             will be used as the default display name.
</span><del>-        @type summary: L{str}
</del><ins>+        @type: L{str}
</ins><span class="cx"> 
</span><ins>+        @param shareName: The proposed name of the new share.
+        @type: L{str}
+
</ins><span class="cx">         @return: the name of the shared calendar in the new calendar home.
</span><span class="cx">         @rtype: L{str}
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="lines">@@ -4863,16 +5025,18 @@
</span><span class="cx"> 
</span><span class="cx">         #remove None parameters, and substitute None for empty string
</span><span class="cx">         bind = self._bindSchema
</span><del>-        columnMap = dict([(k, v if v != &quot;&quot; else None) for k, v in {
-            bind.BIND_MODE:mode,
-            bind.BIND_STATUS:status,
-            bind.MESSAGE:summary
-        }.iteritems() if v is not None])
</del><ins>+        columnMap = {}
+        if mode != None and mode != self._bindMode:
+            columnMap[bind.BIND_MODE] = mode
+        if status != None:# and status != self._bindStatus:  # FIXME:
+            columnMap[bind.BIND_STATUS] = status
+        if summary != None and summary and summary != self._bindMessage:
+            columnMap[bind.MESSAGE] = summary
</ins><span class="cx"> 
</span><span class="cx">         if columnMap:
</span><span class="cx"> 
</span><span class="cx">             # Count accepted
</span><del>-            if status is not None:
</del><ins>+            if bind.BIND_STATUS in columnMap:
</ins><span class="cx">                 previouslyAcceptedCount = yield shareeView._previousAcceptCount()
</span><span class="cx"> 
</span><span class="cx">             yield self._updateBindColumnsQuery(columnMap).on(
</span><span class="lines">@@ -4977,12 +5141,12 @@
</span><span class="cx">             returnValue([])
</span><span class="cx"> 
</span><span class="cx">         # get all accepted binds
</span><del>-        acceptedRows = yield self._sharedInvitationBindForResourceID.on(
</del><ins>+        invitedRows = yield self._sharedInvitationBindForResourceID.on(
</ins><span class="cx">             self._txn, resourceID=self._resourceID, homeID=self._home._resourceID
</span><span class="cx">         )
</span><span class="cx"> 
</span><span class="cx">         result = []
</span><del>-        for homeUID, homeRID, _ignore_resourceID, resourceName, bindMode, bindStatus, bindMessage in acceptedRows:
</del><ins>+        for homeUID, homeRID, _ignore_resourceID, resourceName, bindMode, bindStatus, bindMessage in invitedRows:
</ins><span class="cx">             invite = SharingInvitation(
</span><span class="cx">                 resourceName,
</span><span class="cx">                 self.ownerHome().name(),
</span><span class="lines">@@ -5111,6 +5275,13 @@
</span><span class="cx">         return self._bindMode
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+    def effectiveShareMode(self):
+        &quot;&quot;&quot;
+        @see: L{ICalendar.shareMode}
+        &quot;&quot;&quot;
+        return self._bindMode
+
+
</ins><span class="cx">     def shareName(self):
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         This is a path like name for the resource within the home being shared. For object resource
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoresql_schemacurrentoracledialectsql"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/sql_schema/current-oracle-dialect.sql (13774 => 13775)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/sql_schema/current-oracle-dialect.sql        2014-07-17 19:55:36 UTC (rev 13774)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/current-oracle-dialect.sql        2014-07-17 21:54:34 UTC (rev 13775)
</span><span class="lines">@@ -116,6 +116,9 @@
</span><span class="cx"> insert into CALENDAR_BIND_MODE (DESCRIPTION, ID) values ('write', 2);
</span><span class="cx"> insert into CALENDAR_BIND_MODE (DESCRIPTION, ID) values ('direct', 3);
</span><span class="cx"> insert into CALENDAR_BIND_MODE (DESCRIPTION, ID) values ('indirect', 4);
</span><ins>+insert into CALENDAR_BIND_MODE (DESCRIPTION, ID) values ('group', 5);
+insert into CALENDAR_BIND_MODE (DESCRIPTION, ID) values ('group_read', 6);
+insert into CALENDAR_BIND_MODE (DESCRIPTION, ID) values ('group_write', 7);
</ins><span class="cx"> create table CALENDAR_BIND_STATUS (
</span><span class="cx">     &quot;ID&quot; integer primary key,
</span><span class="cx">     &quot;DESCRIPTION&quot; nvarchar2(16) unique
</span><span class="lines">@@ -402,13 +405,6 @@
</span><span class="cx">     &quot;GROUP_UID&quot; nvarchar2(255)
</span><span class="cx"> );
</span><span class="cx"> 
</span><del>-create table GROUP_ATTENDEE_RECONCILE_WORK (
-    &quot;WORK_ID&quot; integer primary key not null,
-    &quot;JOB_ID&quot; integer not null references JOB,
-    &quot;RESOURCE_ID&quot; integer,
-    &quot;GROUP_ID&quot; integer
-);
-
</del><span class="cx"> create table GROUPS (
</span><span class="cx">     &quot;GROUP_ID&quot; integer primary key,
</span><span class="cx">     &quot;NAME&quot; nvarchar2(255),
</span><span class="lines">@@ -425,6 +421,13 @@
</span><span class="cx">     primary key (&quot;GROUP_ID&quot;, &quot;MEMBER_UID&quot;)
</span><span class="cx"> );
</span><span class="cx"> 
</span><ins>+create table GROUP_ATTENDEE_RECONCILE_WORK (
+    &quot;WORK_ID&quot; integer primary key not null,
+    &quot;JOB_ID&quot; integer not null references JOB,
+    &quot;RESOURCE_ID&quot; integer not null references CALENDAR_OBJECT on delete cascade,
+    &quot;GROUP_ID&quot; integer not null references GROUPS on delete cascade
+);
+
</ins><span class="cx"> create table GROUP_ATTENDEE (
</span><span class="cx">     &quot;GROUP_ID&quot; integer not null references GROUPS on delete cascade,
</span><span class="cx">     &quot;RESOURCE_ID&quot; integer not null references CALENDAR_OBJECT on delete cascade,
</span><span class="lines">@@ -432,6 +435,21 @@
</span><span class="cx">     primary key (&quot;GROUP_ID&quot;, &quot;RESOURCE_ID&quot;)
</span><span class="cx"> );
</span><span class="cx"> 
</span><ins>+create table GROUP_SHAREE_RECONCILE_WORK (
+    &quot;WORK_ID&quot; integer primary key not null,
+    &quot;JOB_ID&quot; integer not null references JOB,
+    &quot;CALENDAR_ID&quot; integer not null references CALENDAR on delete cascade,
+    &quot;GROUP_ID&quot; integer not null references GROUPS on delete cascade
+);
+
+create table GROUP_SHAREE (
+    &quot;GROUP_ID&quot; integer not null references GROUPS on delete cascade,
+    &quot;CALENDAR_ID&quot; integer not null references CALENDAR on delete cascade,
+    &quot;GROUP_BIND_MODE&quot; integer not null,
+    &quot;MEMBERSHIP_HASH&quot; nvarchar2(255), 
+    primary key (&quot;GROUP_ID&quot;, &quot;CALENDAR_ID&quot;)
+);
+
</ins><span class="cx"> create table DELEGATES (
</span><span class="cx">     &quot;DELEGATOR&quot; nvarchar2(255),
</span><span class="cx">     &quot;DELEGATE&quot; nvarchar2(255),
</span><span class="lines">@@ -578,7 +596,7 @@
</span><span class="cx">     &quot;VALUE&quot; nvarchar2(255)
</span><span class="cx"> );
</span><span class="cx"> 
</span><del>-insert into CALENDARSERVER (NAME, VALUE) values ('VERSION', '45');
</del><ins>+insert into CALENDARSERVER (NAME, VALUE) values ('VERSION', '46');
</ins><span class="cx"> insert into CALENDARSERVER (NAME, VALUE) values ('CALENDAR-DATAVERSION', '6');
</span><span class="cx"> insert into CALENDARSERVER (NAME, VALUE) values ('ADDRESSBOOK-DATAVERSION', '2');
</span><span class="cx"> insert into CALENDARSERVER (NAME, VALUE) values ('NOTIFICATION-DATAVERSION', '1');
</span><span class="lines">@@ -736,10 +754,6 @@
</span><span class="cx">     JOB_ID
</span><span class="cx"> );
</span><span class="cx"> 
</span><del>-create index GROUP_ATTENDEE_RECONC_da73d3c2 on GROUP_ATTENDEE_RECONCILE_WORK (
-    JOB_ID
-);
-
</del><span class="cx"> create index GROUPS_GROUP_UID_b35cce23 on GROUPS (
</span><span class="cx">     GROUP_UID
</span><span class="cx"> );
</span><span class="lines">@@ -748,10 +762,38 @@
</span><span class="cx">     MEMBER_UID
</span><span class="cx"> );
</span><span class="cx"> 
</span><ins>+create index GROUP_ATTENDEE_RECONC_da73d3c2 on GROUP_ATTENDEE_RECONCILE_WORK (
+    JOB_ID
+);
+
+create index GROUP_ATTENDEE_RECONC_b894ee7a on GROUP_ATTENDEE_RECONCILE_WORK (
+    RESOURCE_ID
+);
+
+create index GROUP_ATTENDEE_RECONC_5eabc549 on GROUP_ATTENDEE_RECONCILE_WORK (
+    GROUP_ID
+);
+
</ins><span class="cx"> create index GROUP_ATTENDEE_RESOUR_855124dc on GROUP_ATTENDEE (
</span><span class="cx">     RESOURCE_ID
</span><span class="cx"> );
</span><span class="cx"> 
</span><ins>+create index GROUP_SHAREE_RECONCIL_9aad0858 on GROUP_SHAREE_RECONCILE_WORK (
+    JOB_ID
+);
+
+create index GROUP_SHAREE_RECONCIL_4dc60f78 on GROUP_SHAREE_RECONCILE_WORK (
+    CALENDAR_ID
+);
+
+create index GROUP_SHAREE_RECONCIL_1d14c921 on GROUP_SHAREE_RECONCILE_WORK (
+    GROUP_ID
+);
+
+create index GROUP_SHAREE_CALENDAR_28a88850 on GROUP_SHAREE (
+    CALENDAR_ID
+);
+
</ins><span class="cx"> create index DELEGATE_TO_DELEGATOR_5e149b11 on DELEGATES (
</span><span class="cx">     DELEGATE,
</span><span class="cx">     READ_WRITE,
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoresql_schemacurrentsql"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/sql_schema/current.sql (13774 => 13775)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/sql_schema/current.sql        2014-07-17 19:55:36 UTC (rev 13774)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/current.sql        2014-07-17 21:54:34 UTC (rev 13775)
</span><span class="lines">@@ -204,6 +204,9 @@
</span><span class="cx"> insert into CALENDAR_BIND_MODE values (2, 'write');
</span><span class="cx"> insert into CALENDAR_BIND_MODE values (3, 'direct');
</span><span class="cx"> insert into CALENDAR_BIND_MODE values (4, 'indirect');
</span><ins>+insert into CALENDAR_BIND_MODE values (5, 'group');
+insert into CALENDAR_BIND_MODE values (6, 'group_read');
+insert into CALENDAR_BIND_MODE values (7, 'group_write');
</ins><span class="cx"> 
</span><span class="cx"> -- Enumeration of statuses
</span><span class="cx"> 
</span><span class="lines">@@ -759,17 +762,6 @@
</span><span class="cx"> create index GROUP_REFRESH_WORK_JOB_ID on
</span><span class="cx">   GROUP_REFRESH_WORK(JOB_ID);
</span><span class="cx"> 
</span><del>-create table GROUP_ATTENDEE_RECONCILE_WORK (
-  WORK_ID                       integer      primary key default nextval('WORKITEM_SEQ') not null, -- implicit index
-  JOB_ID                        integer      references JOB not null,
-  RESOURCE_ID                   integer,
-  GROUP_ID                      integer
-);
-
-create index GROUP_ATTENDEE_RECONCILE_WORK_JOB_ID on
-  GROUP_ATTENDEE_RECONCILE_WORK(JOB_ID);
-
-
</del><span class="cx"> create table GROUPS (
</span><span class="cx">   GROUP_ID                      integer      primary key default nextval('RESOURCE_ID_SEQ'),    -- implicit index
</span><span class="cx">   NAME                          varchar(255) not null,
</span><span class="lines">@@ -792,6 +784,21 @@
</span><span class="cx"> create index GROUP_MEMBERSHIP_MEMBER on
</span><span class="cx">   GROUP_MEMBERSHIP(MEMBER_UID);
</span><span class="cx"> 
</span><ins>+create table GROUP_ATTENDEE_RECONCILE_WORK (
+  WORK_ID                       integer primary key default nextval('WORKITEM_SEQ') not null, -- implicit index
+  JOB_ID                        integer not null references JOB,
+  RESOURCE_ID                   integer not null references CALENDAR_OBJECT on delete cascade,
+  GROUP_ID                      integer not null references GROUPS on delete cascade
+);
+
+create index GROUP_ATTENDEE_RECONCILE_WORK_JOB_ID on
+  GROUP_ATTENDEE_RECONCILE_WORK(JOB_ID);
+create index GROUP_ATTENDEE_RECONCILE_WORK_RESOURCE_ID on
+  GROUP_ATTENDEE_RECONCILE_WORK(RESOURCE_ID);
+create index GROUP_ATTENDEE_RECONCILE_WORK_GROUP_ID on
+  GROUP_ATTENDEE_RECONCILE_WORK(GROUP_ID);
+
+  
</ins><span class="cx"> create table GROUP_ATTENDEE (
</span><span class="cx">   GROUP_ID                      integer not null references GROUPS on delete cascade,
</span><span class="cx">   RESOURCE_ID                   integer not null references CALENDAR_OBJECT on delete cascade,
</span><span class="lines">@@ -799,9 +806,38 @@
</span><span class="cx">   
</span><span class="cx">   primary key (GROUP_ID, RESOURCE_ID)
</span><span class="cx"> );
</span><ins>+
</ins><span class="cx"> create index GROUP_ATTENDEE_RESOURCE_ID on
</span><span class="cx">   GROUP_ATTENDEE(RESOURCE_ID);
</span><span class="cx"> 
</span><ins>+  
+create table GROUP_SHAREE_RECONCILE_WORK (
+  WORK_ID                       integer primary key default nextval('WORKITEM_SEQ') not null, -- implicit index
+  JOB_ID                        integer not null references JOB,
+  CALENDAR_ID                   integer        not null references CALENDAR on delete cascade,
+  GROUP_ID                      integer not null references GROUPS on delete cascade
+);
+
+create index GROUP_SHAREE_RECONCILE_WORK_JOB_ID on
+  GROUP_SHAREE_RECONCILE_WORK(JOB_ID);
+create index GROUP_SHAREE_RECONCILE_WORK_CALENDAR_ID on
+  GROUP_SHAREE_RECONCILE_WORK(CALENDAR_ID);
+create index GROUP_SHAREE_RECONCILE_WORK_GROUP_ID on
+  GROUP_SHAREE_RECONCILE_WORK(GROUP_ID);
+
+
+create table GROUP_SHAREE (
+  GROUP_ID                      integer not null references GROUPS on delete cascade,
+  CALENDAR_ID                                      integer not null references CALENDAR on delete cascade,
+  GROUP_BIND_MODE               integer not null, -- enum CALENDAR_BIND_MODE
+  MEMBERSHIP_HASH               varchar(255) not null,
+  
+  primary key (GROUP_ID, CALENDAR_ID)
+);
+
+create index GROUP_SHAREE_CALENDAR_ID on
+  GROUP_SHAREE(CALENDAR_ID);
+
</ins><span class="cx"> ---------------
</span><span class="cx"> -- Delegates --
</span><span class="cx"> ---------------
</span><span class="lines">@@ -1091,7 +1127,7 @@
</span><span class="cx">   VALUE                         varchar(255)
</span><span class="cx"> );
</span><span class="cx"> 
</span><del>-insert into CALENDARSERVER values ('VERSION', '45');
</del><ins>+insert into CALENDARSERVER values ('VERSION', '46');
</ins><span class="cx"> insert into CALENDARSERVER values ('CALENDAR-DATAVERSION', '6');
</span><span class="cx"> insert into CALENDARSERVER values ('ADDRESSBOOK-DATAVERSION', '2');
</span><span class="cx"> insert into CALENDARSERVER values ('NOTIFICATION-DATAVERSION', '1');
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoresql_schemaoldoracledialectv45sqlfromrev13773CalendarServerbranchesusersgayagroupsharee2txdavcommondatastoresql_schemaoldoracledialectv45sql"></a>
<div class="copfile"><h4>Copied: CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v45.sql (from rev 13773, CalendarServer/branches/users/gaya/groupsharee2/txdav/common/datastore/sql_schema/old/oracle-dialect/v45.sql) (0 => 13775)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v45.sql                                (rev 0)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/old/oracle-dialect/v45.sql        2014-07-17 21:54:34 UTC (rev 13775)
</span><span class="lines">@@ -0,0 +1,866 @@
</span><ins>+create sequence RESOURCE_ID_SEQ;
+create sequence JOB_SEQ;
+create sequence INSTANCE_ID_SEQ;
+create sequence ATTACHMENT_ID_SEQ;
+create sequence REVISION_SEQ;
+create sequence WORKITEM_SEQ;
+create table NODE_INFO (
+    &quot;HOSTNAME&quot; nvarchar2(255),
+    &quot;PID&quot; integer not null,
+    &quot;PORT&quot; integer not null,
+    &quot;TIME&quot; timestamp default CURRENT_TIMESTAMP at time zone 'UTC' not null, 
+    primary key (&quot;HOSTNAME&quot;, &quot;PORT&quot;)
+);
+
+create table NAMED_LOCK (
+    &quot;LOCK_NAME&quot; nvarchar2(255) primary key
+);
+
+create table JOB (
+    &quot;JOB_ID&quot; integer primary key not null,
+    &quot;WORK_TYPE&quot; nvarchar2(255),
+    &quot;PRIORITY&quot; integer default 0,
+    &quot;WEIGHT&quot; integer default 0,
+    &quot;NOT_BEFORE&quot; timestamp not null,
+    &quot;ASSIGNED&quot; timestamp default null,
+    &quot;OVERDUE&quot; timestamp default null,
+    &quot;FAILED&quot; integer default 0
+);
+
+create table CALENDAR_HOME (
+    &quot;RESOURCE_ID&quot; integer primary key,
+    &quot;OWNER_UID&quot; nvarchar2(255) unique,
+    &quot;STATUS&quot; integer default 0 not null,
+    &quot;DATAVERSION&quot; integer default 0 not null
+);
+
+create table HOME_STATUS (
+    &quot;ID&quot; integer primary key,
+    &quot;DESCRIPTION&quot; nvarchar2(16) unique
+);
+
+insert into HOME_STATUS (DESCRIPTION, ID) values ('normal', 0);
+insert into HOME_STATUS (DESCRIPTION, ID) values ('external', 1);
+insert into HOME_STATUS (DESCRIPTION, ID) values ('purging', 2);
+create table CALENDAR (
+    &quot;RESOURCE_ID&quot; integer primary key
+);
+
+create table CALENDAR_HOME_METADATA (
+    &quot;RESOURCE_ID&quot; integer primary key references CALENDAR_HOME on delete cascade,
+    &quot;QUOTA_USED_BYTES&quot; integer default 0 not null,
+    &quot;DEFAULT_EVENTS&quot; integer default null references CALENDAR on delete set null,
+    &quot;DEFAULT_TASKS&quot; integer default null references CALENDAR on delete set null,
+    &quot;DEFAULT_POLLS&quot; integer default null references CALENDAR on delete set null,
+    &quot;ALARM_VEVENT_TIMED&quot; nclob default null,
+    &quot;ALARM_VEVENT_ALLDAY&quot; nclob default null,
+    &quot;ALARM_VTODO_TIMED&quot; nclob default null,
+    &quot;ALARM_VTODO_ALLDAY&quot; nclob default null,
+    &quot;AVAILABILITY&quot; nclob default null,
+    &quot;CREATED&quot; timestamp default CURRENT_TIMESTAMP at time zone 'UTC',
+    &quot;MODIFIED&quot; timestamp default CURRENT_TIMESTAMP at time zone 'UTC'
+);
+
+create table CALENDAR_METADATA (
+    &quot;RESOURCE_ID&quot; integer primary key references CALENDAR on delete cascade,
+    &quot;SUPPORTED_COMPONENTS&quot; nvarchar2(255) default null,
+    &quot;CREATED&quot; timestamp default CURRENT_TIMESTAMP at time zone 'UTC',
+    &quot;MODIFIED&quot; timestamp default CURRENT_TIMESTAMP at time zone 'UTC'
+);
+
+create table NOTIFICATION_HOME (
+    &quot;RESOURCE_ID&quot; integer primary key,
+    &quot;OWNER_UID&quot; nvarchar2(255) unique,
+    &quot;STATUS&quot; integer default 0 not null,
+    &quot;DATAVERSION&quot; integer default 0 not null
+);
+
+create table NOTIFICATION (
+    &quot;RESOURCE_ID&quot; integer primary key,
+    &quot;NOTIFICATION_HOME_RESOURCE_ID&quot; integer not null references NOTIFICATION_HOME,
+    &quot;NOTIFICATION_UID&quot; nvarchar2(255),
+    &quot;NOTIFICATION_TYPE&quot; nvarchar2(255),
+    &quot;NOTIFICATION_DATA&quot; nclob,
+    &quot;MD5&quot; nchar(32),
+    &quot;CREATED&quot; timestamp default CURRENT_TIMESTAMP at time zone 'UTC',
+    &quot;MODIFIED&quot; timestamp default CURRENT_TIMESTAMP at time zone 'UTC', 
+    unique (&quot;NOTIFICATION_UID&quot;, &quot;NOTIFICATION_HOME_RESOURCE_ID&quot;)
+);
+
+create table CALENDAR_BIND (
+    &quot;CALENDAR_HOME_RESOURCE_ID&quot; integer not null references CALENDAR_HOME,
+    &quot;CALENDAR_RESOURCE_ID&quot; integer not null references CALENDAR on delete cascade,
+    &quot;EXTERNAL_ID&quot; integer default null,
+    &quot;CALENDAR_RESOURCE_NAME&quot; nvarchar2(255),
+    &quot;BIND_MODE&quot; integer not null,
+    &quot;BIND_STATUS&quot; integer not null,
+    &quot;BIND_REVISION&quot; integer default 0 not null,
+    &quot;MESSAGE&quot; nclob,
+    &quot;TRANSP&quot; integer default 0 not null,
+    &quot;ALARM_VEVENT_TIMED&quot; nclob default null,
+    &quot;ALARM_VEVENT_ALLDAY&quot; nclob default null,
+    &quot;ALARM_VTODO_TIMED&quot; nclob default null,
+    &quot;ALARM_VTODO_ALLDAY&quot; nclob default null,
+    &quot;TIMEZONE&quot; nclob default null, 
+    primary key (&quot;CALENDAR_HOME_RESOURCE_ID&quot;, &quot;CALENDAR_RESOURCE_ID&quot;), 
+    unique (&quot;CALENDAR_HOME_RESOURCE_ID&quot;, &quot;CALENDAR_RESOURCE_NAME&quot;)
+);
+
+create table CALENDAR_BIND_MODE (
+    &quot;ID&quot; integer primary key,
+    &quot;DESCRIPTION&quot; nvarchar2(16) unique
+);
+
+insert into CALENDAR_BIND_MODE (DESCRIPTION, ID) values ('own', 0);
+insert into CALENDAR_BIND_MODE (DESCRIPTION, ID) values ('read', 1);
+insert into CALENDAR_BIND_MODE (DESCRIPTION, ID) values ('write', 2);
+insert into CALENDAR_BIND_MODE (DESCRIPTION, ID) values ('direct', 3);
+insert into CALENDAR_BIND_MODE (DESCRIPTION, ID) values ('indirect', 4);
+create table CALENDAR_BIND_STATUS (
+    &quot;ID&quot; integer primary key,
+    &quot;DESCRIPTION&quot; nvarchar2(16) unique
+);
+
+insert into CALENDAR_BIND_STATUS (DESCRIPTION, ID) values ('invited', 0);
+insert into CALENDAR_BIND_STATUS (DESCRIPTION, ID) values ('accepted', 1);
+insert into CALENDAR_BIND_STATUS (DESCRIPTION, ID) values ('declined', 2);
+insert into CALENDAR_BIND_STATUS (DESCRIPTION, ID) values ('invalid', 3);
+insert into CALENDAR_BIND_STATUS (DESCRIPTION, ID) values ('deleted', 4);
+create table CALENDAR_TRANSP (
+    &quot;ID&quot; integer primary key,
+    &quot;DESCRIPTION&quot; nvarchar2(16) unique
+);
+
+insert into CALENDAR_TRANSP (DESCRIPTION, ID) values ('opaque', 0);
+insert into CALENDAR_TRANSP (DESCRIPTION, ID) values ('transparent', 1);
+create table CALENDAR_OBJECT (
+    &quot;RESOURCE_ID&quot; integer primary key,
+    &quot;CALENDAR_RESOURCE_ID&quot; integer not null references CALENDAR on delete cascade,
+    &quot;RESOURCE_NAME&quot; nvarchar2(255),
+    &quot;ICALENDAR_TEXT&quot; nclob,
+    &quot;ICALENDAR_UID&quot; nvarchar2(255),
+    &quot;ICALENDAR_TYPE&quot; nvarchar2(255),
+    &quot;ATTACHMENTS_MODE&quot; integer default 0 not null,
+    &quot;DROPBOX_ID&quot; nvarchar2(255),
+    &quot;ORGANIZER&quot; nvarchar2(255),
+    &quot;RECURRANCE_MIN&quot; date,
+    &quot;RECURRANCE_MAX&quot; date,
+    &quot;ACCESS&quot; integer default 0 not null,
+    &quot;SCHEDULE_OBJECT&quot; integer default 0,
+    &quot;SCHEDULE_TAG&quot; nvarchar2(36) default null,
+    &quot;SCHEDULE_ETAGS&quot; nclob default null,
+    &quot;PRIVATE_COMMENTS&quot; integer default 0 not null,
+    &quot;MD5&quot; nchar(32),
+    &quot;CREATED&quot; timestamp default CURRENT_TIMESTAMP at time zone 'UTC',
+    &quot;MODIFIED&quot; timestamp default CURRENT_TIMESTAMP at time zone 'UTC',
+    &quot;DATAVERSION&quot; integer default 0 not null, 
+    unique (&quot;CALENDAR_RESOURCE_ID&quot;, &quot;RESOURCE_NAME&quot;)
+);
+
+create table CALENDAR_OBJ_ATTACHMENTS_MODE (
+    &quot;ID&quot; integer primary key,
+    &quot;DESCRIPTION&quot; nvarchar2(16) unique
+);
+
+insert into CALENDAR_OBJ_ATTACHMENTS_MODE (DESCRIPTION, ID) values ('none', 0);
+insert into CALENDAR_OBJ_ATTACHMENTS_MODE (DESCRIPTION, ID) values ('read', 1);
+insert into CALENDAR_OBJ_ATTACHMENTS_MODE (DESCRIPTION, ID) values ('write', 2);
+create table CALENDAR_ACCESS_TYPE (
+    &quot;ID&quot; integer primary key,
+    &quot;DESCRIPTION&quot; nvarchar2(32) unique
+);
+
+insert into CALENDAR_ACCESS_TYPE (DESCRIPTION, ID) values ('', 0);
+insert into CALENDAR_ACCESS_TYPE (DESCRIPTION, ID) values ('public', 1);
+insert into CALENDAR_ACCESS_TYPE (DESCRIPTION, ID) values ('private', 2);
+insert into CALENDAR_ACCESS_TYPE (DESCRIPTION, ID) values ('confidential', 3);
+insert into CALENDAR_ACCESS_TYPE (DESCRIPTION, ID) values ('restricted', 4);
+create table TIME_RANGE (
+    &quot;INSTANCE_ID&quot; integer primary key,
+    &quot;CALENDAR_RESOURCE_ID&quot; integer not null references CALENDAR on delete cascade,
+    &quot;CALENDAR_OBJECT_RESOURCE_ID&quot; integer not null references CALENDAR_OBJECT on delete cascade,
+    &quot;FLOATING&quot; integer not null,
+    &quot;START_DATE&quot; timestamp not null,
+    &quot;END_DATE&quot; timestamp not null,
+    &quot;FBTYPE&quot; integer not null,
+    &quot;TRANSPARENT&quot; integer not null
+);
+
+create table FREE_BUSY_TYPE (
+    &quot;ID&quot; integer primary key,
+    &quot;DESCRIPTION&quot; nvarchar2(16) unique
+);
+
+insert into FREE_BUSY_TYPE (DESCRIPTION, ID) values ('unknown', 0);
+insert into FREE_BUSY_TYPE (DESCRIPTION, ID) values ('free', 1);
+insert into FREE_BUSY_TYPE (DESCRIPTION, ID) values ('busy', 2);
+insert into FREE_BUSY_TYPE (DESCRIPTION, ID) values ('busy-unavailable', 3);
+insert into FREE_BUSY_TYPE (DESCRIPTION, ID) values ('busy-tentative', 4);
+create table PERUSER (
+    &quot;TIME_RANGE_INSTANCE_ID&quot; integer not null references TIME_RANGE on delete cascade,
+    &quot;USER_ID&quot; nvarchar2(255),
+    &quot;TRANSPARENT&quot; integer not null,
+    &quot;ADJUSTED_START_DATE&quot; timestamp default null,
+    &quot;ADJUSTED_END_DATE&quot; timestamp default null
+);
+
+create table ATTACHMENT (
+    &quot;ATTACHMENT_ID&quot; integer primary key,
+    &quot;CALENDAR_HOME_RESOURCE_ID&quot; integer not null references CALENDAR_HOME,
+    &quot;DROPBOX_ID&quot; nvarchar2(255),
+    &quot;CONTENT_TYPE&quot; nvarchar2(255),
+    &quot;SIZE&quot; integer not null,
+    &quot;MD5&quot; nchar(32),
+    &quot;CREATED&quot; timestamp default CURRENT_TIMESTAMP at time zone 'UTC',
+    &quot;MODIFIED&quot; timestamp default CURRENT_TIMESTAMP at time zone 'UTC',
+    &quot;PATH&quot; nvarchar2(1024)
+);
+
+create table ATTACHMENT_CALENDAR_OBJECT (
+    &quot;ATTACHMENT_ID&quot; integer not null references ATTACHMENT on delete cascade,
+    &quot;MANAGED_ID&quot; nvarchar2(255),
+    &quot;CALENDAR_OBJECT_RESOURCE_ID&quot; integer not null references CALENDAR_OBJECT on delete cascade, 
+    primary key (&quot;ATTACHMENT_ID&quot;, &quot;CALENDAR_OBJECT_RESOURCE_ID&quot;), 
+    unique (&quot;MANAGED_ID&quot;, &quot;CALENDAR_OBJECT_RESOURCE_ID&quot;)
+);
+
+create table RESOURCE_PROPERTY (
+    &quot;RESOURCE_ID&quot; integer not null,
+    &quot;NAME&quot; nvarchar2(255),
+    &quot;VALUE&quot; nclob,
+    &quot;VIEWER_UID&quot; nvarchar2(255), 
+    primary key (&quot;RESOURCE_ID&quot;, &quot;NAME&quot;, &quot;VIEWER_UID&quot;)
+);
+
+create table ADDRESSBOOK_HOME (
+    &quot;RESOURCE_ID&quot; integer primary key,
+    &quot;ADDRESSBOOK_PROPERTY_STORE_ID&quot; integer not null,
+    &quot;OWNER_UID&quot; nvarchar2(255) unique,
+    &quot;STATUS&quot; integer default 0 not null,
+    &quot;DATAVERSION&quot; integer default 0 not null
+);
+
+create table ADDRESSBOOK_HOME_METADATA (
+    &quot;RESOURCE_ID&quot; integer primary key references ADDRESSBOOK_HOME on delete cascade,
+    &quot;QUOTA_USED_BYTES&quot; integer default 0 not null,
+    &quot;CREATED&quot; timestamp default CURRENT_TIMESTAMP at time zone 'UTC',
+    &quot;MODIFIED&quot; timestamp default CURRENT_TIMESTAMP at time zone 'UTC'
+);
+
+create table SHARED_ADDRESSBOOK_BIND (
+    &quot;ADDRESSBOOK_HOME_RESOURCE_ID&quot; integer not null references ADDRESSBOOK_HOME,
+    &quot;OWNER_HOME_RESOURCE_ID&quot; integer not null references ADDRESSBOOK_HOME on delete cascade,
+    &quot;EXTERNAL_ID&quot; integer default null,
+    &quot;ADDRESSBOOK_RESOURCE_NAME&quot; nvarchar2(255),
+    &quot;BIND_MODE&quot; integer not null,
+    &quot;BIND_STATUS&quot; integer not null,
+    &quot;BIND_REVISION&quot; integer default 0 not null,
+    &quot;MESSAGE&quot; nclob, 
+    primary key (&quot;ADDRESSBOOK_HOME_RESOURCE_ID&quot;, &quot;OWNER_HOME_RESOURCE_ID&quot;), 
+    unique (&quot;ADDRESSBOOK_HOME_RESOURCE_ID&quot;, &quot;ADDRESSBOOK_RESOURCE_NAME&quot;)
+);
+
+create table ADDRESSBOOK_OBJECT (
+    &quot;RESOURCE_ID&quot; integer primary key,
+    &quot;ADDRESSBOOK_HOME_RESOURCE_ID&quot; integer not null references ADDRESSBOOK_HOME on delete cascade,
+    &quot;RESOURCE_NAME&quot; nvarchar2(255),
+    &quot;VCARD_TEXT&quot; nclob,
+    &quot;VCARD_UID&quot; nvarchar2(255),
+    &quot;KIND&quot; integer not null,
+    &quot;MD5&quot; nchar(32),
+    &quot;CREATED&quot; timestamp default CURRENT_TIMESTAMP at time zone 'UTC',
+    &quot;MODIFIED&quot; timestamp default CURRENT_TIMESTAMP at time zone 'UTC',
+    &quot;DATAVERSION&quot; integer default 0 not null, 
+    unique (&quot;ADDRESSBOOK_HOME_RESOURCE_ID&quot;, &quot;RESOURCE_NAME&quot;), 
+    unique (&quot;ADDRESSBOOK_HOME_RESOURCE_ID&quot;, &quot;VCARD_UID&quot;)
+);
+
+create table ADDRESSBOOK_OBJECT_KIND (
+    &quot;ID&quot; integer primary key,
+    &quot;DESCRIPTION&quot; nvarchar2(16) unique
+);
+
+insert into ADDRESSBOOK_OBJECT_KIND (DESCRIPTION, ID) values ('person', 0);
+insert into ADDRESSBOOK_OBJECT_KIND (DESCRIPTION, ID) values ('group', 1);
+insert into ADDRESSBOOK_OBJECT_KIND (DESCRIPTION, ID) values ('resource', 2);
+insert into ADDRESSBOOK_OBJECT_KIND (DESCRIPTION, ID) values ('location', 3);
+create table ABO_MEMBERS (
+    &quot;GROUP_ID&quot; integer not null,
+    &quot;ADDRESSBOOK_ID&quot; integer not null references ADDRESSBOOK_HOME on delete cascade,
+    &quot;MEMBER_ID&quot; integer not null,
+    &quot;REVISION&quot; integer not null,
+    &quot;REMOVED&quot; integer default 0 not null,
+    &quot;MODIFIED&quot; timestamp default CURRENT_TIMESTAMP at time zone 'UTC', 
+    primary key (&quot;GROUP_ID&quot;, &quot;MEMBER_ID&quot;, &quot;REVISION&quot;)
+);
+
+create table ABO_FOREIGN_MEMBERS (
+    &quot;GROUP_ID&quot; integer not null references ADDRESSBOOK_OBJECT on delete cascade,
+    &quot;ADDRESSBOOK_ID&quot; integer not null references ADDRESSBOOK_HOME on delete cascade,
+    &quot;MEMBER_ADDRESS&quot; nvarchar2(255), 
+    primary key (&quot;GROUP_ID&quot;, &quot;MEMBER_ADDRESS&quot;)
+);
+
+create table SHARED_GROUP_BIND (
+    &quot;ADDRESSBOOK_HOME_RESOURCE_ID&quot; integer not null references ADDRESSBOOK_HOME,
+    &quot;GROUP_RESOURCE_ID&quot; integer not null references ADDRESSBOOK_OBJECT on delete cascade,
+    &quot;EXTERNAL_ID&quot; integer default null,
+    &quot;GROUP_ADDRESSBOOK_NAME&quot; nvarchar2(255),
+    &quot;BIND_MODE&quot; integer not null,
+    &quot;BIND_STATUS&quot; integer not null,
+    &quot;BIND_REVISION&quot; integer default 0 not null,
+    &quot;MESSAGE&quot; nclob, 
+    primary key (&quot;ADDRESSBOOK_HOME_RESOURCE_ID&quot;, &quot;GROUP_RESOURCE_ID&quot;), 
+    unique (&quot;ADDRESSBOOK_HOME_RESOURCE_ID&quot;, &quot;GROUP_ADDRESSBOOK_NAME&quot;)
+);
+
+create table CALENDAR_OBJECT_REVISIONS (
+    &quot;CALENDAR_HOME_RESOURCE_ID&quot; integer not null references CALENDAR_HOME,
+    &quot;CALENDAR_RESOURCE_ID&quot; integer references CALENDAR,
+    &quot;CALENDAR_NAME&quot; nvarchar2(255) default null,
+    &quot;RESOURCE_NAME&quot; nvarchar2(255),
+    &quot;REVISION&quot; integer not null,
+    &quot;DELETED&quot; integer not null,
+    &quot;MODIFIED&quot; timestamp default CURRENT_TIMESTAMP at time zone 'UTC'
+);
+
+create table ADDRESSBOOK_OBJECT_REVISIONS (
+    &quot;ADDRESSBOOK_HOME_RESOURCE_ID&quot; integer not null references ADDRESSBOOK_HOME,
+    &quot;OWNER_HOME_RESOURCE_ID&quot; integer references ADDRESSBOOK_HOME,
+    &quot;ADDRESSBOOK_NAME&quot; nvarchar2(255) default null,
+    &quot;OBJECT_RESOURCE_ID&quot; integer default 0,
+    &quot;RESOURCE_NAME&quot; nvarchar2(255),
+    &quot;REVISION&quot; integer not null,
+    &quot;DELETED&quot; integer not null,
+    &quot;MODIFIED&quot; timestamp default CURRENT_TIMESTAMP at time zone 'UTC'
+);
+
+create table NOTIFICATION_OBJECT_REVISIONS (
+    &quot;NOTIFICATION_HOME_RESOURCE_ID&quot; integer not null references NOTIFICATION_HOME on delete cascade,
+    &quot;RESOURCE_NAME&quot; nvarchar2(255),
+    &quot;REVISION&quot; integer not null,
+    &quot;DELETED&quot; integer not null,
+    &quot;MODIFIED&quot; timestamp default CURRENT_TIMESTAMP at time zone 'UTC', 
+    unique (&quot;NOTIFICATION_HOME_RESOURCE_ID&quot;, &quot;RESOURCE_NAME&quot;)
+);
+
+create table APN_SUBSCRIPTIONS (
+    &quot;TOKEN&quot; nvarchar2(255),
+    &quot;RESOURCE_KEY&quot; nvarchar2(255),
+    &quot;MODIFIED&quot; integer not null,
+    &quot;SUBSCRIBER_GUID&quot; nvarchar2(255),
+    &quot;USER_AGENT&quot; nvarchar2(255) default null,
+    &quot;IP_ADDR&quot; nvarchar2(255) default null, 
+    primary key (&quot;TOKEN&quot;, &quot;RESOURCE_KEY&quot;)
+);
+
+create table IMIP_TOKENS (
+    &quot;TOKEN&quot; nvarchar2(255),
+    &quot;ORGANIZER&quot; nvarchar2(255),
+    &quot;ATTENDEE&quot; nvarchar2(255),
+    &quot;ICALUID&quot; nvarchar2(255),
+    &quot;ACCESSED&quot; timestamp default CURRENT_TIMESTAMP at time zone 'UTC', 
+    primary key (&quot;ORGANIZER&quot;, &quot;ATTENDEE&quot;, &quot;ICALUID&quot;)
+);
+
+create table IMIP_INVITATION_WORK (
+    &quot;WORK_ID&quot; integer primary key not null,
+    &quot;JOB_ID&quot; integer not null references JOB,
+    &quot;FROM_ADDR&quot; nvarchar2(255),
+    &quot;TO_ADDR&quot; nvarchar2(255),
+    &quot;ICALENDAR_TEXT&quot; nclob
+);
+
+create table IMIP_POLLING_WORK (
+    &quot;WORK_ID&quot; integer primary key not null,
+    &quot;JOB_ID&quot; integer not null references JOB
+);
+
+create table IMIP_REPLY_WORK (
+    &quot;WORK_ID&quot; integer primary key not null,
+    &quot;JOB_ID&quot; integer not null references JOB,
+    &quot;ORGANIZER&quot; nvarchar2(255),
+    &quot;ATTENDEE&quot; nvarchar2(255),
+    &quot;ICALENDAR_TEXT&quot; nclob
+);
+
+create table PUSH_NOTIFICATION_WORK (
+    &quot;WORK_ID&quot; integer primary key not null,
+    &quot;JOB_ID&quot; integer not null references JOB,
+    &quot;PUSH_ID&quot; nvarchar2(255),
+    &quot;PUSH_PRIORITY&quot; integer not null
+);
+
+create table GROUP_CACHER_POLLING_WORK (
+    &quot;WORK_ID&quot; integer primary key not null,
+    &quot;JOB_ID&quot; integer not null references JOB
+);
+
+create table GROUP_REFRESH_WORK (
+    &quot;WORK_ID&quot; integer primary key not null,
+    &quot;JOB_ID&quot; integer not null references JOB,
+    &quot;GROUP_UID&quot; nvarchar2(255)
+);
+
+create table GROUP_ATTENDEE_RECONCILE_WORK (
+    &quot;WORK_ID&quot; integer primary key not null,
+    &quot;JOB_ID&quot; integer not null references JOB,
+    &quot;RESOURCE_ID&quot; integer,
+    &quot;GROUP_ID&quot; integer
+);
+
+create table GROUPS (
+    &quot;GROUP_ID&quot; integer primary key,
+    &quot;NAME&quot; nvarchar2(255),
+    &quot;GROUP_UID&quot; nvarchar2(255),
+    &quot;MEMBERSHIP_HASH&quot; nvarchar2(255),
+    &quot;EXTANT&quot; integer default 1,
+    &quot;CREATED&quot; timestamp default CURRENT_TIMESTAMP at time zone 'UTC',
+    &quot;MODIFIED&quot; timestamp default CURRENT_TIMESTAMP at time zone 'UTC'
+);
+
+create table GROUP_MEMBERSHIP (
+    &quot;GROUP_ID&quot; integer not null references GROUPS on delete cascade,
+    &quot;MEMBER_UID&quot; nvarchar2(255), 
+    primary key (&quot;GROUP_ID&quot;, &quot;MEMBER_UID&quot;)
+);
+
+create table GROUP_ATTENDEE (
+    &quot;GROUP_ID&quot; integer not null references GROUPS on delete cascade,
+    &quot;RESOURCE_ID&quot; integer not null references CALENDAR_OBJECT on delete cascade,
+    &quot;MEMBERSHIP_HASH&quot; nvarchar2(255), 
+    primary key (&quot;GROUP_ID&quot;, &quot;RESOURCE_ID&quot;)
+);
+
+create table DELEGATES (
+    &quot;DELEGATOR&quot; nvarchar2(255),
+    &quot;DELEGATE&quot; nvarchar2(255),
+    &quot;READ_WRITE&quot; integer not null, 
+    primary key (&quot;DELEGATOR&quot;, &quot;READ_WRITE&quot;, &quot;DELEGATE&quot;)
+);
+
+create table DELEGATE_GROUPS (
+    &quot;DELEGATOR&quot; nvarchar2(255),
+    &quot;GROUP_ID&quot; integer not null references GROUPS on delete cascade,
+    &quot;READ_WRITE&quot; integer not null,
+    &quot;IS_EXTERNAL&quot; integer not null, 
+    primary key (&quot;DELEGATOR&quot;, &quot;READ_WRITE&quot;, &quot;GROUP_ID&quot;)
+);
+
+create table EXTERNAL_DELEGATE_GROUPS (
+    &quot;DELEGATOR&quot; nvarchar2(255) primary key,
+    &quot;GROUP_UID_READ&quot; nvarchar2(255),
+    &quot;GROUP_UID_WRITE&quot; nvarchar2(255)
+);
+
+create table CALENDAR_OBJECT_SPLITTER_WORK (
+    &quot;WORK_ID&quot; integer primary key not null,
+    &quot;JOB_ID&quot; integer not null references JOB,
+    &quot;RESOURCE_ID&quot; integer not null references CALENDAR_OBJECT on delete cascade
+);
+
+create table FIND_MIN_VALID_REVISION_WORK (
+    &quot;WORK_ID&quot; integer primary key not null,
+    &quot;JOB_ID&quot; integer not null references JOB
+);
+
+create table REVISION_CLEANUP_WORK (
+    &quot;WORK_ID&quot; integer primary key not null,
+    &quot;JOB_ID&quot; integer not null references JOB
+);
+
+create table INBOX_CLEANUP_WORK (
+    &quot;WORK_ID&quot; integer primary key not null,
+    &quot;JOB_ID&quot; integer not null references JOB
+);
+
+create table CLEANUP_ONE_INBOX_WORK (
+    &quot;WORK_ID&quot; integer primary key not null,
+    &quot;JOB_ID&quot; integer not null references JOB,
+    &quot;HOME_ID&quot; integer not null unique references CALENDAR_HOME on delete cascade
+);
+
+create table SCHEDULE_WORK (
+    &quot;WORK_ID&quot; integer primary key not null,
+    &quot;JOB_ID&quot; integer not null references JOB,
+    &quot;ICALENDAR_UID&quot; nvarchar2(255),
+    &quot;WORK_TYPE&quot; nvarchar2(255)
+);
+
+create table SCHEDULE_REFRESH_WORK (
+    &quot;WORK_ID&quot; integer primary key references SCHEDULE_WORK on delete cascade,
+    &quot;HOME_RESOURCE_ID&quot; integer not null references CALENDAR_HOME on delete cascade,
+    &quot;RESOURCE_ID&quot; integer not null references CALENDAR_OBJECT on delete cascade,
+    &quot;ATTENDEE_COUNT&quot; integer
+);
+
+create table SCHEDULE_REFRESH_ATTENDEES (
+    &quot;RESOURCE_ID&quot; integer not null references CALENDAR_OBJECT on delete cascade,
+    &quot;ATTENDEE&quot; nvarchar2(255), 
+    primary key (&quot;RESOURCE_ID&quot;, &quot;ATTENDEE&quot;)
+);
+
+create table SCHEDULE_AUTO_REPLY_WORK (
+    &quot;WORK_ID&quot; integer primary key references SCHEDULE_WORK on delete cascade,
+    &quot;HOME_RESOURCE_ID&quot; integer not null references CALENDAR_HOME on delete cascade,
+    &quot;RESOURCE_ID&quot; integer not null references CALENDAR_OBJECT on delete cascade,
+    &quot;PARTSTAT&quot; nvarchar2(255)
+);
+
+create table SCHEDULE_ORGANIZER_WORK (
+    &quot;WORK_ID&quot; integer primary key references SCHEDULE_WORK on delete cascade,
+    &quot;SCHEDULE_ACTION&quot; integer not null,
+    &quot;HOME_RESOURCE_ID&quot; integer not null references CALENDAR_HOME on delete cascade,
+    &quot;RESOURCE_ID&quot; integer,
+    &quot;ICALENDAR_TEXT_OLD&quot; nclob,
+    &quot;ICALENDAR_TEXT_NEW&quot; nclob,
+    &quot;ATTENDEE_COUNT&quot; integer,
+    &quot;SMART_MERGE&quot; integer
+);
+
+create table SCHEDULE_ACTION (
+    &quot;ID&quot; integer primary key,
+    &quot;DESCRIPTION&quot; nvarchar2(16) unique
+);
+
+insert into SCHEDULE_ACTION (DESCRIPTION, ID) values ('create', 0);
+insert into SCHEDULE_ACTION (DESCRIPTION, ID) values ('modify', 1);
+insert into SCHEDULE_ACTION (DESCRIPTION, ID) values ('modify-cancelled', 2);
+insert into SCHEDULE_ACTION (DESCRIPTION, ID) values ('remove', 3);
+create table SCHEDULE_ORGANIZER_SEND_WORK (
+    &quot;WORK_ID&quot; integer primary key references SCHEDULE_WORK on delete cascade,
+    &quot;SCHEDULE_ACTION&quot; integer not null,
+    &quot;HOME_RESOURCE_ID&quot; integer not null references CALENDAR_HOME on delete cascade,
+    &quot;RESOURCE_ID&quot; integer,
+    &quot;ATTENDEE&quot; nvarchar2(255),
+    &quot;ITIP_MSG&quot; nclob,
+    &quot;NO_REFRESH&quot; integer
+);
+
+create table SCHEDULE_REPLY_WORK (
+    &quot;WORK_ID&quot; integer primary key references SCHEDULE_WORK on delete cascade,
+    &quot;HOME_RESOURCE_ID&quot; integer not null references CALENDAR_HOME on delete cascade,
+    &quot;RESOURCE_ID&quot; integer not null references CALENDAR_OBJECT on delete cascade,
+    &quot;CHANGED_RIDS&quot; nclob
+);
+
+create table SCHEDULE_REPLY_CANCEL_WORK (
+    &quot;WORK_ID&quot; integer primary key references SCHEDULE_WORK on delete cascade,
+    &quot;HOME_RESOURCE_ID&quot; integer not null references CALENDAR_HOME on delete cascade,
+    &quot;ICALENDAR_TEXT&quot; nclob
+);
+
+create table PRINCIPAL_PURGE_POLLING_WORK (
+    &quot;WORK_ID&quot; integer primary key not null,
+    &quot;JOB_ID&quot; integer not null references JOB
+);
+
+create table PRINCIPAL_PURGE_CHECK_WORK (
+    &quot;WORK_ID&quot; integer primary key not null,
+    &quot;JOB_ID&quot; integer not null references JOB,
+    &quot;UID&quot; nvarchar2(255)
+);
+
+create table PRINCIPAL_PURGE_WORK (
+    &quot;WORK_ID&quot; integer primary key not null,
+    &quot;JOB_ID&quot; integer not null references JOB,
+    &quot;UID&quot; nvarchar2(255)
+);
+
+create table PRINCIPAL_PURGE_HOME_WORK (
+    &quot;WORK_ID&quot; integer primary key not null,
+    &quot;JOB_ID&quot; integer not null references JOB,
+    &quot;HOME_RESOURCE_ID&quot; integer not null references CALENDAR_HOME on delete cascade
+);
+
+create table CALENDARSERVER (
+    &quot;NAME&quot; nvarchar2(255) primary key,
+    &quot;VALUE&quot; nvarchar2(255)
+);
+
+insert into CALENDARSERVER (NAME, VALUE) values ('VERSION', '45');
+insert into CALENDARSERVER (NAME, VALUE) values ('CALENDAR-DATAVERSION', '6');
+insert into CALENDARSERVER (NAME, VALUE) values ('ADDRESSBOOK-DATAVERSION', '2');
+insert into CALENDARSERVER (NAME, VALUE) values ('NOTIFICATION-DATAVERSION', '1');
+insert into CALENDARSERVER (NAME, VALUE) values ('MIN-VALID-REVISION', '1');
+create index CALENDAR_HOME_METADAT_3cb9049e on CALENDAR_HOME_METADATA (
+    DEFAULT_EVENTS
+);
+
+create index CALENDAR_HOME_METADAT_d55e5548 on CALENDAR_HOME_METADATA (
+    DEFAULT_TASKS
+);
+
+create index CALENDAR_HOME_METADAT_910264ce on CALENDAR_HOME_METADATA (
+    DEFAULT_POLLS
+);
+
+create index NOTIFICATION_NOTIFICA_f891f5f9 on NOTIFICATION (
+    NOTIFICATION_HOME_RESOURCE_ID
+);
+
+create index CALENDAR_BIND_RESOURC_e57964d4 on CALENDAR_BIND (
+    CALENDAR_RESOURCE_ID
+);
+
+create index CALENDAR_OBJECT_CALEN_a9a453a9 on CALENDAR_OBJECT (
+    CALENDAR_RESOURCE_ID,
+    ICALENDAR_UID
+);
+
+create index CALENDAR_OBJECT_CALEN_96e83b73 on CALENDAR_OBJECT (
+    CALENDAR_RESOURCE_ID,
+    RECURRANCE_MAX
+);
+
+create index CALENDAR_OBJECT_ICALE_82e731d5 on CALENDAR_OBJECT (
+    ICALENDAR_UID
+);
+
+create index CALENDAR_OBJECT_DROPB_de041d80 on CALENDAR_OBJECT (
+    DROPBOX_ID
+);
+
+create index TIME_RANGE_CALENDAR_R_beb6e7eb on TIME_RANGE (
+    CALENDAR_RESOURCE_ID
+);
+
+create index TIME_RANGE_CALENDAR_O_acf37bd1 on TIME_RANGE (
+    CALENDAR_OBJECT_RESOURCE_ID
+);
+
+create index PERUSER_TIME_RANGE_IN_5468a226 on PERUSER (
+    TIME_RANGE_INSTANCE_ID
+);
+
+create index ATTACHMENT_CALENDAR_H_0078845c on ATTACHMENT (
+    CALENDAR_HOME_RESOURCE_ID
+);
+
+create index ATTACHMENT_DROPBOX_ID_5073cf23 on ATTACHMENT (
+    DROPBOX_ID
+);
+
+create index ATTACHMENT_CALENDAR_O_81508484 on ATTACHMENT_CALENDAR_OBJECT (
+    CALENDAR_OBJECT_RESOURCE_ID
+);
+
+create index SHARED_ADDRESSBOOK_BI_e9a2e6d4 on SHARED_ADDRESSBOOK_BIND (
+    OWNER_HOME_RESOURCE_ID
+);
+
+create index ABO_MEMBERS_ADDRESSBO_4effa879 on ABO_MEMBERS (
+    ADDRESSBOOK_ID
+);
+
+create index ABO_MEMBERS_MEMBER_ID_8d66adcf on ABO_MEMBERS (
+    MEMBER_ID
+);
+
+create index ABO_FOREIGN_MEMBERS_A_1fd2c5e9 on ABO_FOREIGN_MEMBERS (
+    ADDRESSBOOK_ID
+);
+
+create index SHARED_GROUP_BIND_RES_cf52f95d on SHARED_GROUP_BIND (
+    GROUP_RESOURCE_ID
+);
+
+create index CALENDAR_OBJECT_REVIS_3a3956c4 on CALENDAR_OBJECT_REVISIONS (
+    CALENDAR_HOME_RESOURCE_ID,
+    CALENDAR_RESOURCE_ID
+);
+
+create index CALENDAR_OBJECT_REVIS_6d9d929c on CALENDAR_OBJECT_REVISIONS (
+    CALENDAR_RESOURCE_ID,
+    RESOURCE_NAME,
+    DELETED,
+    REVISION
+);
+
+create index CALENDAR_OBJECT_REVIS_265c8acf on CALENDAR_OBJECT_REVISIONS (
+    CALENDAR_RESOURCE_ID,
+    REVISION
+);
+
+create index ADDRESSBOOK_OBJECT_RE_2bfcf757 on ADDRESSBOOK_OBJECT_REVISIONS (
+    ADDRESSBOOK_HOME_RESOURCE_ID,
+    OWNER_HOME_RESOURCE_ID
+);
+
+create index ADDRESSBOOK_OBJECT_RE_00fe8288 on ADDRESSBOOK_OBJECT_REVISIONS (
+    OWNER_HOME_RESOURCE_ID,
+    RESOURCE_NAME,
+    DELETED,
+    REVISION
+);
+
+create index ADDRESSBOOK_OBJECT_RE_45004780 on ADDRESSBOOK_OBJECT_REVISIONS (
+    OWNER_HOME_RESOURCE_ID,
+    REVISION
+);
+
+create index NOTIFICATION_OBJECT_R_036a9cee on NOTIFICATION_OBJECT_REVISIONS (
+    NOTIFICATION_HOME_RESOURCE_ID,
+    REVISION
+);
+
+create index APN_SUBSCRIPTIONS_RES_9610d78e on APN_SUBSCRIPTIONS (
+    RESOURCE_KEY
+);
+
+create index IMIP_TOKENS_TOKEN_e94b918f on IMIP_TOKENS (
+    TOKEN
+);
+
+create index IMIP_INVITATION_WORK__586d064c on IMIP_INVITATION_WORK (
+    JOB_ID
+);
+
+create index IMIP_POLLING_WORK_JOB_d5535891 on IMIP_POLLING_WORK (
+    JOB_ID
+);
+
+create index IMIP_REPLY_WORK_JOB_I_bf4ae73e on IMIP_REPLY_WORK (
+    JOB_ID
+);
+
+create index PUSH_NOTIFICATION_WOR_8bbab117 on PUSH_NOTIFICATION_WORK (
+    JOB_ID
+);
+
+create index GROUP_CACHER_POLLING__6eb3151c on GROUP_CACHER_POLLING_WORK (
+    JOB_ID
+);
+
+create index GROUP_REFRESH_WORK_JO_717ede20 on GROUP_REFRESH_WORK (
+    JOB_ID
+);
+
+create index GROUP_ATTENDEE_RECONC_da73d3c2 on GROUP_ATTENDEE_RECONCILE_WORK (
+    JOB_ID
+);
+
+create index GROUPS_GROUP_UID_b35cce23 on GROUPS (
+    GROUP_UID
+);
+
+create index GROUP_MEMBERSHIP_MEMB_0ca508e8 on GROUP_MEMBERSHIP (
+    MEMBER_UID
+);
+
+create index GROUP_ATTENDEE_RESOUR_855124dc on GROUP_ATTENDEE (
+    RESOURCE_ID
+);
+
+create index DELEGATE_TO_DELEGATOR_5e149b11 on DELEGATES (
+    DELEGATE,
+    READ_WRITE,
+    DELEGATOR
+);
+
+create index DELEGATE_GROUPS_GROUP_25117446 on DELEGATE_GROUPS (
+    GROUP_ID
+);
+
+create index CALENDAR_OBJECT_SPLIT_af71dcda on CALENDAR_OBJECT_SPLITTER_WORK (
+    RESOURCE_ID
+);
+
+create index CALENDAR_OBJECT_SPLIT_33603b72 on CALENDAR_OBJECT_SPLITTER_WORK (
+    JOB_ID
+);
+
+create index FIND_MIN_VALID_REVISI_78d17400 on FIND_MIN_VALID_REVISION_WORK (
+    JOB_ID
+);
+
+create index REVISION_CLEANUP_WORK_eb062686 on REVISION_CLEANUP_WORK (
+    JOB_ID
+);
+
+create index INBOX_CLEANUP_WORK_JO_799132bd on INBOX_CLEANUP_WORK (
+    JOB_ID
+);
+
+create index CLEANUP_ONE_INBOX_WOR_375dac36 on CLEANUP_ONE_INBOX_WORK (
+    JOB_ID
+);
+
+create index SCHEDULE_WORK_JOB_ID_65e810ee on SCHEDULE_WORK (
+    JOB_ID
+);
+
+create index SCHEDULE_WORK_ICALEND_089f33dc on SCHEDULE_WORK (
+    ICALENDAR_UID
+);
+
+create index SCHEDULE_REFRESH_WORK_26084c7b on SCHEDULE_REFRESH_WORK (
+    HOME_RESOURCE_ID
+);
+
+create index SCHEDULE_REFRESH_WORK_989efe54 on SCHEDULE_REFRESH_WORK (
+    RESOURCE_ID
+);
+
+create index SCHEDULE_REFRESH_ATTE_83053b91 on SCHEDULE_REFRESH_ATTENDEES (
+    RESOURCE_ID,
+    ATTENDEE
+);
+
+create index SCHEDULE_AUTO_REPLY_W_0256478d on SCHEDULE_AUTO_REPLY_WORK (
+    HOME_RESOURCE_ID
+);
+
+create index SCHEDULE_AUTO_REPLY_W_0755e754 on SCHEDULE_AUTO_REPLY_WORK (
+    RESOURCE_ID
+);
+
+create index SCHEDULE_ORGANIZER_WO_18ce4edd on SCHEDULE_ORGANIZER_WORK (
+    HOME_RESOURCE_ID
+);
+
+create index SCHEDULE_ORGANIZER_WO_14702035 on SCHEDULE_ORGANIZER_WORK (
+    RESOURCE_ID
+);
+
+create index SCHEDULE_ORGANIZER_SE_9ec9f827 on SCHEDULE_ORGANIZER_SEND_WORK (
+    HOME_RESOURCE_ID
+);
+
+create index SCHEDULE_ORGANIZER_SE_699fefc4 on SCHEDULE_ORGANIZER_SEND_WORK (
+    RESOURCE_ID
+);
+
+create index SCHEDULE_REPLY_WORK_H_745af8cf on SCHEDULE_REPLY_WORK (
+    HOME_RESOURCE_ID
+);
+
+create index SCHEDULE_REPLY_WORK_R_11bd3fbb on SCHEDULE_REPLY_WORK (
+    RESOURCE_ID
+);
+
+create index SCHEDULE_REPLY_CANCEL_dab513ef on SCHEDULE_REPLY_CANCEL_WORK (
+    HOME_RESOURCE_ID
+);
+
+create index PRINCIPAL_PURGE_POLLI_6383e68a on PRINCIPAL_PURGE_POLLING_WORK (
+    JOB_ID
+);
+
+create index PRINCIPAL_PURGE_CHECK_b0c024c1 on PRINCIPAL_PURGE_CHECK_WORK (
+    JOB_ID
+);
+
+create index PRINCIPAL_PURGE_WORK__7a8141a3 on PRINCIPAL_PURGE_WORK (
+    JOB_ID
+);
+
+create index PRINCIPAL_PURGE_HOME__f35eea7a on PRINCIPAL_PURGE_HOME_WORK (
+    JOB_ID
+);
+
+create index PRINCIPAL_PURGE_HOME__967e4480 on PRINCIPAL_PURGE_HOME_WORK (
+    HOME_RESOURCE_ID
+);
+
+-- Extra schema to add to current-oracle-dialect.sql
</ins></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoresql_schemaoldpostgresdialectv45sqlfromrev13773CalendarServerbranchesusersgayagroupsharee2txdavcommondatastoresql_schemaoldpostgresdialectv45sql"></a>
<div class="copfile"><h4>Copied: CalendarServer/trunk/txdav/common/datastore/sql_schema/old/postgres-dialect/v45.sql (from rev 13773, CalendarServer/branches/users/gaya/groupsharee2/txdav/common/datastore/sql_schema/old/postgres-dialect/v45.sql) (0 => 13775)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/sql_schema/old/postgres-dialect/v45.sql                                (rev 0)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/old/postgres-dialect/v45.sql        2014-07-17 21:54:34 UTC (rev 13775)
</span><span class="lines">@@ -0,0 +1,1098 @@
</span><ins>+-- -*- test-case-name: txdav.caldav.datastore.test.test_sql,txdav.carddav.datastore.test.test_sql -*-
+
+----
+-- Copyright (c) 2010-2014 Apple Inc. All rights reserved.
+--
+-- Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
+-- 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 &quot;AS IS&quot; 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.
+----
+
+
+-----------------
+-- Resource ID --
+-----------------
+
+create sequence RESOURCE_ID_SEQ;
+
+
+-------------------------
+-- Cluster Bookkeeping --
+-------------------------
+
+-- Information about a process connected to this database.
+
+-- Note that this must match the node info schema in twext.enterprise.queue.
+create table NODE_INFO (
+  HOSTNAME  varchar(255) not null,
+  PID       integer      not null,
+  PORT      integer      not null,
+  TIME      timestamp    not null default timezone('UTC', CURRENT_TIMESTAMP),
+
+  primary key (HOSTNAME, PORT)
+);
+
+-- Unique named locks.  This table should always be empty, but rows are
+-- temporarily created in order to prevent undesirable concurrency.
+create table NAMED_LOCK (
+    LOCK_NAME varchar(255) primary key
+);
+
+
+--------------------
+-- Jobs           --
+--------------------
+
+create sequence JOB_SEQ;
+
+create table JOB (
+  JOB_ID      integer primary key default nextval('JOB_SEQ') not null, --implicit index
+  WORK_TYPE   varchar(255) not null,
+  PRIORITY    integer default 0,
+  WEIGHT      integer default 0,
+  NOT_BEFORE  timestamp not null,
+  ASSIGNED    timestamp default null,
+  OVERDUE     timestamp default null,
+  FAILED      integer default 0
+);
+
+-------------------
+-- Calendar Home --
+-------------------
+
+create table CALENDAR_HOME (
+  RESOURCE_ID      integer      primary key default nextval('RESOURCE_ID_SEQ'), -- implicit index
+  OWNER_UID        varchar(255) not null unique,                                -- implicit index
+  STATUS           integer      default 0 not null,                             -- enum HOME_STATUS
+  DATAVERSION      integer      default 0 not null
+);
+
+-- Enumeration of statuses
+
+create table HOME_STATUS (
+  ID          integer     primary key,
+  DESCRIPTION varchar(16) not null unique
+);
+
+insert into HOME_STATUS values (0, 'normal' );
+insert into HOME_STATUS values (1, 'external');
+insert into HOME_STATUS values (2, 'purging');
+
+
+--------------
+-- Calendar --
+--------------
+
+create table CALENDAR (
+  RESOURCE_ID integer   primary key default nextval('RESOURCE_ID_SEQ') -- implicit index
+);
+
+
+----------------------------
+-- Calendar Home Metadata --
+----------------------------
+
+create table CALENDAR_HOME_METADATA (
+  RESOURCE_ID              integer     primary key references CALENDAR_HOME on delete cascade, -- implicit index
+  QUOTA_USED_BYTES         integer     default 0 not null,
+  DEFAULT_EVENTS           integer     default null references CALENDAR on delete set null,
+  DEFAULT_TASKS            integer     default null references CALENDAR on delete set null,
+  DEFAULT_POLLS            integer     default null references CALENDAR on delete set null,
+  ALARM_VEVENT_TIMED       text        default null,
+  ALARM_VEVENT_ALLDAY      text        default null,
+  ALARM_VTODO_TIMED        text        default null,
+  ALARM_VTODO_ALLDAY       text        default null,
+  AVAILABILITY             text        default null,
+  CREATED                  timestamp   default timezone('UTC', CURRENT_TIMESTAMP),
+  MODIFIED                 timestamp   default timezone('UTC', CURRENT_TIMESTAMP)
+);
+
+create index CALENDAR_HOME_METADATA_DEFAULT_EVENTS on
+  CALENDAR_HOME_METADATA(DEFAULT_EVENTS);
+create index CALENDAR_HOME_METADATA_DEFAULT_TASKS on
+  CALENDAR_HOME_METADATA(DEFAULT_TASKS);
+create index CALENDAR_HOME_METADATA_DEFAULT_POLLS on
+  CALENDAR_HOME_METADATA(DEFAULT_POLLS);
+
+
+-----------------------
+-- Calendar Metadata --
+-----------------------
+
+create table CALENDAR_METADATA (
+  RESOURCE_ID           integer      primary key references CALENDAR on delete cascade, -- implicit index
+  SUPPORTED_COMPONENTS  varchar(255) default null,
+  CREATED               timestamp    default timezone('UTC', CURRENT_TIMESTAMP),
+  MODIFIED              timestamp    default timezone('UTC', CURRENT_TIMESTAMP)
+);
+
+
+---------------------------
+-- Sharing Notifications --
+---------------------------
+
+create table NOTIFICATION_HOME (
+  RESOURCE_ID integer      primary key default nextval('RESOURCE_ID_SEQ'), -- implicit index
+  OWNER_UID   varchar(255) not null unique,                                -- implicit index
+  STATUS      integer      default 0 not null,                             -- enum HOME_STATUS
+  DATAVERSION integer      default 0 not null
+);
+
+create table NOTIFICATION (
+  RESOURCE_ID                   integer      primary key default nextval('RESOURCE_ID_SEQ'), -- implicit index
+  NOTIFICATION_HOME_RESOURCE_ID integer      not null references NOTIFICATION_HOME,
+  NOTIFICATION_UID              varchar(255) not null,
+  NOTIFICATION_TYPE             varchar(255) not null,
+  NOTIFICATION_DATA             text         not null,
+  MD5                           char(32)     not null,
+  CREATED                       timestamp    default timezone('UTC', CURRENT_TIMESTAMP),
+  MODIFIED                      timestamp    default timezone('UTC', CURRENT_TIMESTAMP),
+
+  unique (NOTIFICATION_UID, NOTIFICATION_HOME_RESOURCE_ID) -- implicit index
+);
+
+create index NOTIFICATION_NOTIFICATION_HOME_RESOURCE_ID on
+  NOTIFICATION(NOTIFICATION_HOME_RESOURCE_ID);
+
+
+-------------------
+-- Calendar Bind --
+-------------------
+
+-- Joins CALENDAR_HOME and CALENDAR
+
+create table CALENDAR_BIND (
+  CALENDAR_HOME_RESOURCE_ID integer      not null references CALENDAR_HOME,
+  CALENDAR_RESOURCE_ID      integer      not null references CALENDAR on delete cascade,
+  EXTERNAL_ID               integer      default null,
+  CALENDAR_RESOURCE_NAME    varchar(255) not null,
+  BIND_MODE                 integer      not null, -- enum CALENDAR_BIND_MODE
+  BIND_STATUS               integer      not null, -- enum CALENDAR_BIND_STATUS
+  BIND_REVISION             integer      default 0 not null,
+  MESSAGE                   text,
+  TRANSP                    integer      default 0 not null, -- enum CALENDAR_TRANSP
+  ALARM_VEVENT_TIMED        text         default null,
+  ALARM_VEVENT_ALLDAY       text         default null,
+  ALARM_VTODO_TIMED         text         default null,
+  ALARM_VTODO_ALLDAY        text         default null,
+  TIMEZONE                  text         default null,
+
+  primary key (CALENDAR_HOME_RESOURCE_ID, CALENDAR_RESOURCE_ID), -- implicit index
+  unique (CALENDAR_HOME_RESOURCE_ID, CALENDAR_RESOURCE_NAME)     -- implicit index
+);
+
+create index CALENDAR_BIND_RESOURCE_ID on
+  CALENDAR_BIND(CALENDAR_RESOURCE_ID);
+
+-- Enumeration of calendar bind modes
+
+create table CALENDAR_BIND_MODE (
+  ID          integer     primary key,
+  DESCRIPTION varchar(16) not null unique
+);
+
+insert into CALENDAR_BIND_MODE values (0, 'own'  );
+insert into CALENDAR_BIND_MODE values (1, 'read' );
+insert into CALENDAR_BIND_MODE values (2, 'write');
+insert into CALENDAR_BIND_MODE values (3, 'direct');
+insert into CALENDAR_BIND_MODE values (4, 'indirect');
+
+-- Enumeration of statuses
+
+create table CALENDAR_BIND_STATUS (
+  ID          integer     primary key,
+  DESCRIPTION varchar(16) not null unique
+);
+
+insert into CALENDAR_BIND_STATUS values (0, 'invited' );
+insert into CALENDAR_BIND_STATUS values (1, 'accepted');
+insert into CALENDAR_BIND_STATUS values (2, 'declined');
+insert into CALENDAR_BIND_STATUS values (3, 'invalid');
+insert into CALENDAR_BIND_STATUS values (4, 'deleted');
+
+
+-- Enumeration of transparency
+
+create table CALENDAR_TRANSP (
+  ID          integer     primary key,
+  DESCRIPTION varchar(16) not null unique
+);
+
+insert into CALENDAR_TRANSP values (0, 'opaque' );
+insert into CALENDAR_TRANSP values (1, 'transparent');
+
+
+---------------------
+-- Calendar Object --
+---------------------
+
+create table CALENDAR_OBJECT (
+  RESOURCE_ID          integer      primary key default nextval('RESOURCE_ID_SEQ'), -- implicit index
+  CALENDAR_RESOURCE_ID integer      not null references CALENDAR on delete cascade,
+  RESOURCE_NAME        varchar(255) not null,
+  ICALENDAR_TEXT       text         not null,
+  ICALENDAR_UID        varchar(255) not null,
+  ICALENDAR_TYPE       varchar(255) not null,
+  ATTACHMENTS_MODE     integer      default 0 not null, -- enum CALENDAR_OBJ_ATTACHMENTS_MODE
+  DROPBOX_ID           varchar(255),
+  ORGANIZER            varchar(255),
+  RECURRANCE_MIN       date,        -- minimum date that recurrences have been expanded to.
+  RECURRANCE_MAX       date,        -- maximum date that recurrences have been expanded to.
+  ACCESS               integer      default 0 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,
+  MD5                  char(32)     not null,
+  CREATED              timestamp    default timezone('UTC', CURRENT_TIMESTAMP),
+  MODIFIED             timestamp    default timezone('UTC', CURRENT_TIMESTAMP),
+  DATAVERSION          integer      default 0 not null,
+
+  unique (CALENDAR_RESOURCE_ID, RESOURCE_NAME) -- implicit index
+
+  -- since the 'inbox' is a 'calendar resource' for the purpose of storing
+  -- calendar objects, this constraint has to be selectively enforced by the
+  -- application layer.
+
+  -- unique (CALENDAR_RESOURCE_ID, ICALENDAR_UID)
+);
+
+create index CALENDAR_OBJECT_CALENDAR_RESOURCE_ID_AND_ICALENDAR_UID on
+  CALENDAR_OBJECT(CALENDAR_RESOURCE_ID, ICALENDAR_UID);
+
+create index CALENDAR_OBJECT_CALENDAR_RESOURCE_ID_RECURRANCE_MAX on
+  CALENDAR_OBJECT(CALENDAR_RESOURCE_ID, RECURRANCE_MAX);
+
+create index CALENDAR_OBJECT_ICALENDAR_UID on
+  CALENDAR_OBJECT(ICALENDAR_UID);
+
+create index CALENDAR_OBJECT_DROPBOX_ID on
+  CALENDAR_OBJECT(DROPBOX_ID);
+
+-- Enumeration of attachment modes
+
+create table CALENDAR_OBJ_ATTACHMENTS_MODE (
+  ID          integer     primary key,
+  DESCRIPTION varchar(16) not null unique
+);
+
+insert into CALENDAR_OBJ_ATTACHMENTS_MODE values (0, 'none' );
+insert into CALENDAR_OBJ_ATTACHMENTS_MODE values (1, 'read' );
+insert into CALENDAR_OBJ_ATTACHMENTS_MODE values (2, 'write');
+
+
+-- Enumeration of calendar access types
+
+create table CALENDAR_ACCESS_TYPE (
+  ID          integer     primary key,
+  DESCRIPTION varchar(32) not null unique
+);
+
+insert into CALENDAR_ACCESS_TYPE values (0, ''             );
+insert into CALENDAR_ACCESS_TYPE values (1, 'public'       );
+insert into CALENDAR_ACCESS_TYPE values (2, 'private'      );
+insert into CALENDAR_ACCESS_TYPE values (3, 'confidential' );
+insert into CALENDAR_ACCESS_TYPE values (4, 'restricted'   );
+
+
+-----------------
+-- Instance ID --
+-----------------
+
+create sequence INSTANCE_ID_SEQ;
+
+
+----------------
+-- Time Range --
+----------------
+
+create table TIME_RANGE (
+  INSTANCE_ID                 integer        primary key default nextval('INSTANCE_ID_SEQ'), -- implicit index
+  CALENDAR_RESOURCE_ID        integer        not null references CALENDAR on delete cascade,
+  CALENDAR_OBJECT_RESOURCE_ID integer        not null references CALENDAR_OBJECT on delete cascade,
+  FLOATING                    boolean        not null,
+  START_DATE                  timestamp      not null,
+  END_DATE                    timestamp      not null,
+  FBTYPE                      integer        not null,
+  TRANSPARENT                 boolean        not null
+);
+
+create index TIME_RANGE_CALENDAR_RESOURCE_ID on
+  TIME_RANGE(CALENDAR_RESOURCE_ID);
+create index TIME_RANGE_CALENDAR_OBJECT_RESOURCE_ID on
+  TIME_RANGE(CALENDAR_OBJECT_RESOURCE_ID);
+
+
+-- Enumeration of free/busy types
+
+create table FREE_BUSY_TYPE (
+  ID          integer     primary key,
+  DESCRIPTION varchar(16) not null unique
+);
+
+insert into FREE_BUSY_TYPE values (0, 'unknown'         );
+insert into FREE_BUSY_TYPE values (1, 'free'            );
+insert into FREE_BUSY_TYPE values (2, 'busy'            );
+insert into FREE_BUSY_TYPE values (3, 'busy-unavailable');
+insert into FREE_BUSY_TYPE values (4, 'busy-tentative'  );
+
+
+-------------------
+-- Per-user data --
+-------------------
+
+create table PERUSER (
+  TIME_RANGE_INSTANCE_ID      integer      not null references TIME_RANGE on delete cascade,
+  USER_ID                     varchar(255) not null,
+  TRANSPARENT                 boolean      not null,
+  ADJUSTED_START_DATE         timestamp    default null,
+  ADJUSTED_END_DATE           timestamp    default null
+);
+
+create index PERUSER_TIME_RANGE_INSTANCE_ID on
+  PERUSER(TIME_RANGE_INSTANCE_ID);
+
+
+----------------
+-- Attachment --
+----------------
+
+create sequence ATTACHMENT_ID_SEQ;
+
+create table ATTACHMENT (
+  ATTACHMENT_ID               integer           primary key default nextval('ATTACHMENT_ID_SEQ'), -- implicit index
+  CALENDAR_HOME_RESOURCE_ID   integer           not null references CALENDAR_HOME,
+  DROPBOX_ID                  varchar(255),
+  CONTENT_TYPE                varchar(255)      not null,
+  SIZE                        integer           not null,
+  MD5                         char(32)          not null,
+  CREATED                     timestamp default timezone('UTC', CURRENT_TIMESTAMP),
+  MODIFIED                    timestamp default timezone('UTC', CURRENT_TIMESTAMP),
+  PATH                        varchar(1024)     not null
+);
+
+create index ATTACHMENT_CALENDAR_HOME_RESOURCE_ID on
+  ATTACHMENT(CALENDAR_HOME_RESOURCE_ID);
+
+create index ATTACHMENT_DROPBOX_ID on
+  ATTACHMENT(DROPBOX_ID);
+
+-- Many-to-many relationship between attachments and calendar objects
+create table ATTACHMENT_CALENDAR_OBJECT (
+  ATTACHMENT_ID                  integer      not null references ATTACHMENT on delete cascade,
+  MANAGED_ID                     varchar(255) not null,
+  CALENDAR_OBJECT_RESOURCE_ID    integer      not null references CALENDAR_OBJECT on delete cascade,
+
+  primary key (ATTACHMENT_ID, CALENDAR_OBJECT_RESOURCE_ID), -- implicit index
+  unique (MANAGED_ID, CALENDAR_OBJECT_RESOURCE_ID) --implicit index
+);
+
+create index ATTACHMENT_CALENDAR_OBJECT_CALENDAR_OBJECT_RESOURCE_ID on
+  ATTACHMENT_CALENDAR_OBJECT(CALENDAR_OBJECT_RESOURCE_ID);
+
+-----------------------
+-- Resource Property --
+-----------------------
+
+create table RESOURCE_PROPERTY (
+  RESOURCE_ID integer      not null, -- foreign key: *.RESOURCE_ID
+  NAME        varchar(255) not null,
+  VALUE       text         not null, -- FIXME: xml?
+  VIEWER_UID  varchar(255),
+
+  primary key (RESOURCE_ID, NAME, VIEWER_UID) -- implicit index
+);
+
+
+----------------------
+-- AddressBook Home --
+----------------------
+
+create table ADDRESSBOOK_HOME (
+  RESOURCE_ID                   integer         primary key default nextval('RESOURCE_ID_SEQ'), -- implicit index
+  ADDRESSBOOK_PROPERTY_STORE_ID integer         default nextval('RESOURCE_ID_SEQ') not null,    -- implicit index
+  OWNER_UID                     varchar(255)    not null unique,                                -- implicit index
+  STATUS                        integer         default 0 not null,                             -- enum HOME_STATUS
+  DATAVERSION                   integer         default 0 not null
+);
+
+
+-------------------------------
+-- AddressBook Home Metadata --
+-------------------------------
+
+create table ADDRESSBOOK_HOME_METADATA (
+  RESOURCE_ID      integer      primary key references ADDRESSBOOK_HOME on delete cascade, -- implicit index
+  QUOTA_USED_BYTES integer      default 0 not null,
+  CREATED          timestamp    default timezone('UTC', CURRENT_TIMESTAMP),
+  MODIFIED         timestamp    default timezone('UTC', CURRENT_TIMESTAMP)
+);
+
+
+-----------------------------
+-- Shared AddressBook Bind --
+-----------------------------
+
+-- Joins sharee ADDRESSBOOK_HOME and owner ADDRESSBOOK_HOME
+
+create table SHARED_ADDRESSBOOK_BIND (
+  ADDRESSBOOK_HOME_RESOURCE_ID          integer         not null references ADDRESSBOOK_HOME,
+  OWNER_HOME_RESOURCE_ID                integer         not null references ADDRESSBOOK_HOME on delete cascade,
+  EXTERNAL_ID                           integer         default null,
+  ADDRESSBOOK_RESOURCE_NAME             varchar(255)    not null,
+  BIND_MODE                             integer         not null, -- enum CALENDAR_BIND_MODE
+  BIND_STATUS                           integer         not null, -- enum CALENDAR_BIND_STATUS
+  BIND_REVISION                         integer         default 0 not null,
+  MESSAGE                               text,                     -- FIXME: xml?
+
+  primary key (ADDRESSBOOK_HOME_RESOURCE_ID, OWNER_HOME_RESOURCE_ID), -- implicit index
+  unique (ADDRESSBOOK_HOME_RESOURCE_ID, ADDRESSBOOK_RESOURCE_NAME)     -- implicit index
+);
+
+create index SHARED_ADDRESSBOOK_BIND_RESOURCE_ID on
+  SHARED_ADDRESSBOOK_BIND(OWNER_HOME_RESOURCE_ID);
+
+
+------------------------
+-- AddressBook Object --
+------------------------
+
+create table ADDRESSBOOK_OBJECT (
+  RESOURCE_ID                   integer         primary key default nextval('RESOURCE_ID_SEQ'),    -- implicit index
+  ADDRESSBOOK_HOME_RESOURCE_ID  integer         not null references ADDRESSBOOK_HOME on delete cascade,
+  RESOURCE_NAME                 varchar(255)    not null,
+  VCARD_TEXT                    text            not null,
+  VCARD_UID                     varchar(255)    not null,
+  KIND                          integer         not null,  -- enum ADDRESSBOOK_OBJECT_KIND
+  MD5                           char(32)        not null,
+  CREATED                       timestamp       default timezone('UTC', CURRENT_TIMESTAMP),
+  MODIFIED                      timestamp       default timezone('UTC', CURRENT_TIMESTAMP),
+  DATAVERSION                   integer         default 0 not null,
+
+  unique (ADDRESSBOOK_HOME_RESOURCE_ID, RESOURCE_NAME), -- implicit index
+  unique (ADDRESSBOOK_HOME_RESOURCE_ID, VCARD_UID)      -- implicit index
+);
+
+
+-----------------------------
+-- AddressBook Object kind --
+-----------------------------
+
+create table ADDRESSBOOK_OBJECT_KIND (
+  ID          integer     primary key,
+  DESCRIPTION varchar(16) not null unique
+);
+
+insert into ADDRESSBOOK_OBJECT_KIND values (0, 'person');
+insert into ADDRESSBOOK_OBJECT_KIND values (1, 'group' );
+insert into ADDRESSBOOK_OBJECT_KIND values (2, 'resource');
+insert into ADDRESSBOOK_OBJECT_KIND values (3, 'location');
+
+
+----------------------------------
+-- Revisions, forward reference --
+----------------------------------
+
+create sequence REVISION_SEQ;
+
+---------------------------------
+-- Address Book Object Members --
+---------------------------------
+
+create table ABO_MEMBERS (
+  GROUP_ID        integer     not null, -- references ADDRESSBOOK_OBJECT on delete cascade,   -- AddressBook Object's (kind=='group') RESOURCE_ID
+  ADDRESSBOOK_ID  integer     not null references ADDRESSBOOK_HOME on delete cascade,
+  MEMBER_ID       integer     not null, -- references ADDRESSBOOK_OBJECT,                     -- member AddressBook Object's RESOURCE_ID
+  REVISION        integer     default nextval('REVISION_SEQ') not null,
+  REMOVED         boolean     default false not null,
+  MODIFIED        timestamp   default timezone('UTC', CURRENT_TIMESTAMP),
+
+    primary key (GROUP_ID, MEMBER_ID, REVISION) -- implicit index
+);
+
+create index ABO_MEMBERS_ADDRESSBOOK_ID on
+  ABO_MEMBERS(ADDRESSBOOK_ID);
+create index ABO_MEMBERS_MEMBER_ID on
+  ABO_MEMBERS(MEMBER_ID);
+
+------------------------------------------
+-- Address Book Object Foreign Members  --
+------------------------------------------
+
+create table ABO_FOREIGN_MEMBERS (
+  GROUP_ID           integer      not null references ADDRESSBOOK_OBJECT on delete cascade,  -- AddressBook Object's (kind=='group') RESOURCE_ID
+  ADDRESSBOOK_ID     integer      not null references ADDRESSBOOK_HOME on delete cascade,
+  MEMBER_ADDRESS     varchar(255) not null,                                                  -- member AddressBook Object's 'calendar' address
+
+  primary key (GROUP_ID, MEMBER_ADDRESS) -- implicit index
+);
+
+create index ABO_FOREIGN_MEMBERS_ADDRESSBOOK_ID on
+  ABO_FOREIGN_MEMBERS(ADDRESSBOOK_ID);
+
+-----------------------
+-- Shared Group Bind --
+-----------------------
+
+-- Joins ADDRESSBOOK_HOME and ADDRESSBOOK_OBJECT (kind == group)
+
+create table SHARED_GROUP_BIND (
+  ADDRESSBOOK_HOME_RESOURCE_ID      integer      not null references ADDRESSBOOK_HOME,
+  GROUP_RESOURCE_ID                 integer      not null references ADDRESSBOOK_OBJECT on delete cascade,
+  EXTERNAL_ID                       integer      default null,
+  GROUP_ADDRESSBOOK_NAME            varchar(255) not null,
+  BIND_MODE                         integer      not null, -- enum CALENDAR_BIND_MODE
+  BIND_STATUS                       integer      not null, -- enum CALENDAR_BIND_STATUS
+  BIND_REVISION                     integer      default 0 not null,
+  MESSAGE                           text,                  -- FIXME: xml?
+
+  primary key (ADDRESSBOOK_HOME_RESOURCE_ID, GROUP_RESOURCE_ID), -- implicit index
+  unique (ADDRESSBOOK_HOME_RESOURCE_ID, GROUP_ADDRESSBOOK_NAME)  -- implicit index
+);
+
+create index SHARED_GROUP_BIND_RESOURCE_ID on
+  SHARED_GROUP_BIND(GROUP_RESOURCE_ID);
+
+
+---------------
+-- Revisions --
+---------------
+
+-- create sequence REVISION_SEQ;
+
+
+-------------------------------
+-- Calendar Object Revisions --
+-------------------------------
+
+create table CALENDAR_OBJECT_REVISIONS (
+  CALENDAR_HOME_RESOURCE_ID integer      not null references CALENDAR_HOME,
+  CALENDAR_RESOURCE_ID      integer      references CALENDAR,
+  CALENDAR_NAME             varchar(255) default null,
+  RESOURCE_NAME             varchar(255),
+  REVISION                  integer      default nextval('REVISION_SEQ') not null,
+  DELETED                   boolean      not null,
+  MODIFIED                  timestamp    default timezone('UTC', CURRENT_TIMESTAMP)
+);
+
+create index CALENDAR_OBJECT_REVISIONS_HOME_RESOURCE_ID_CALENDAR_RESOURCE_ID
+  on CALENDAR_OBJECT_REVISIONS(CALENDAR_HOME_RESOURCE_ID, CALENDAR_RESOURCE_ID);
+
+create index CALENDAR_OBJECT_REVISIONS_RESOURCE_ID_RESOURCE_NAME_DELETED_REVISION
+  on CALENDAR_OBJECT_REVISIONS(CALENDAR_RESOURCE_ID, RESOURCE_NAME, DELETED, REVISION);
+
+create index CALENDAR_OBJECT_REVISIONS_RESOURCE_ID_REVISION
+  on CALENDAR_OBJECT_REVISIONS(CALENDAR_RESOURCE_ID, REVISION);
+
+
+----------------------------------
+-- AddressBook Object Revisions --
+----------------------------------
+
+create table ADDRESSBOOK_OBJECT_REVISIONS (
+  ADDRESSBOOK_HOME_RESOURCE_ID  integer      not null references ADDRESSBOOK_HOME,
+  OWNER_HOME_RESOURCE_ID        integer      references ADDRESSBOOK_HOME,
+  ADDRESSBOOK_NAME              varchar(255) default null,
+  OBJECT_RESOURCE_ID            integer      default 0,
+  RESOURCE_NAME                 varchar(255),
+  REVISION                      integer      default nextval('REVISION_SEQ') not null,
+  DELETED                       boolean      not null,
+  MODIFIED                      timestamp    default timezone('UTC', CURRENT_TIMESTAMP)
+);
+
+create index ADDRESSBOOK_OBJECT_REVISIONS_HOME_RESOURCE_ID_OWNER_HOME_RESOURCE_ID
+  on ADDRESSBOOK_OBJECT_REVISIONS(ADDRESSBOOK_HOME_RESOURCE_ID, OWNER_HOME_RESOURCE_ID);
+
+create index ADDRESSBOOK_OBJECT_REVISIONS_OWNER_HOME_RESOURCE_ID_RESOURCE_NAME_DELETED_REVISION
+  on ADDRESSBOOK_OBJECT_REVISIONS(OWNER_HOME_RESOURCE_ID, RESOURCE_NAME, DELETED, REVISION);
+
+create index ADDRESSBOOK_OBJECT_REVISIONS_OWNER_HOME_RESOURCE_ID_REVISION
+  on ADDRESSBOOK_OBJECT_REVISIONS(OWNER_HOME_RESOURCE_ID, REVISION);
+
+
+-----------------------------------
+-- Notification Object Revisions --
+-----------------------------------
+
+create table NOTIFICATION_OBJECT_REVISIONS (
+  NOTIFICATION_HOME_RESOURCE_ID integer      not null references NOTIFICATION_HOME on delete cascade,
+  RESOURCE_NAME                 varchar(255),
+  REVISION                      integer      default nextval('REVISION_SEQ') not null,
+  DELETED                       boolean      not null,
+  MODIFIED                      timestamp    default timezone('UTC', CURRENT_TIMESTAMP),
+
+  unique (NOTIFICATION_HOME_RESOURCE_ID, RESOURCE_NAME) -- implicit index
+);
+
+create index NOTIFICATION_OBJECT_REVISIONS_RESOURCE_ID_REVISION
+  on NOTIFICATION_OBJECT_REVISIONS(NOTIFICATION_HOME_RESOURCE_ID, REVISION);
+
+
+-------------------------------------------
+-- Apple Push Notification Subscriptions --
+-------------------------------------------
+
+create table APN_SUBSCRIPTIONS (
+  TOKEN                         varchar(255) not null,
+  RESOURCE_KEY                  varchar(255) not null,
+  MODIFIED                      integer      not null,
+  SUBSCRIBER_GUID               varchar(255) not null,
+  USER_AGENT                    varchar(255) default null,
+  IP_ADDR                       varchar(255) default null,
+
+  primary key (TOKEN, RESOURCE_KEY) -- implicit index
+);
+
+create index APN_SUBSCRIPTIONS_RESOURCE_KEY
+  on APN_SUBSCRIPTIONS(RESOURCE_KEY);
+
+
+-----------------
+-- IMIP Tokens --
+-----------------
+
+create table IMIP_TOKENS (
+  TOKEN                         varchar(255) not null,
+  ORGANIZER                     varchar(255) not null,
+  ATTENDEE                      varchar(255) not null,
+  ICALUID                       varchar(255) not null,
+  ACCESSED                      timestamp    default timezone('UTC', CURRENT_TIMESTAMP),
+
+  primary key (ORGANIZER, ATTENDEE, ICALUID) -- implicit index
+);
+
+create index IMIP_TOKENS_TOKEN
+  on IMIP_TOKENS(TOKEN);
+
+
+----------------
+-- Work Items --
+----------------
+
+create sequence WORKITEM_SEQ;
+
+
+---------------------------
+-- IMIP Inivitation Work --
+---------------------------
+
+create table IMIP_INVITATION_WORK (
+  WORK_ID                       integer      primary key default nextval('WORKITEM_SEQ') not null, -- implicit index
+  JOB_ID                        integer      references JOB not null,
+  FROM_ADDR                     varchar(255) not null,
+  TO_ADDR                       varchar(255) not null,
+  ICALENDAR_TEXT                text         not null
+);
+
+create index IMIP_INVITATION_WORK_JOB_ID on
+  IMIP_INVITATION_WORK(JOB_ID);
+
+-----------------------
+-- IMIP Polling Work --
+-----------------------
+
+create table IMIP_POLLING_WORK (
+  WORK_ID                       integer      primary key default nextval('WORKITEM_SEQ') not null, -- implicit index
+  JOB_ID                        integer      references JOB not null
+);
+
+create index IMIP_POLLING_WORK_JOB_ID on
+  IMIP_POLLING_WORK(JOB_ID);
+
+
+---------------------
+-- IMIP Reply Work --
+---------------------
+
+create table IMIP_REPLY_WORK (
+  WORK_ID                       integer      primary key default nextval('WORKITEM_SEQ') not null, -- implicit index
+  JOB_ID                        integer      references JOB not null,
+  ORGANIZER                     varchar(255) not null,
+  ATTENDEE                      varchar(255) not null,
+  ICALENDAR_TEXT                text         not null
+);
+
+create index IMIP_REPLY_WORK_JOB_ID on
+  IMIP_REPLY_WORK(JOB_ID);
+
+
+------------------------
+-- Push Notifications --
+------------------------
+
+create table PUSH_NOTIFICATION_WORK (
+  WORK_ID                       integer      primary key default nextval('WORKITEM_SEQ') not null, -- implicit index
+  JOB_ID                        integer      references JOB not null,
+  PUSH_ID                       varchar(255) not null,
+  PUSH_PRIORITY                 integer      not null -- 1:low 5:medium 10:high
+);
+
+create index PUSH_NOTIFICATION_WORK_JOB_ID on
+  PUSH_NOTIFICATION_WORK(JOB_ID);
+
+-----------------
+-- GroupCacher --
+-----------------
+
+create table GROUP_CACHER_POLLING_WORK (
+  WORK_ID                       integer      primary key default nextval('WORKITEM_SEQ') not null, -- implicit index
+  JOB_ID                        integer      references JOB not null
+);
+
+create index GROUP_CACHER_POLLING_WORK_JOB_ID on
+  GROUP_CACHER_POLLING_WORK(JOB_ID);
+
+create table GROUP_REFRESH_WORK (
+  WORK_ID                       integer      primary key default nextval('WORKITEM_SEQ') not null, -- implicit index
+  JOB_ID                        integer      references JOB not null,
+  GROUP_UID                     varchar(255) not null
+);
+
+create index GROUP_REFRESH_WORK_JOB_ID on
+  GROUP_REFRESH_WORK(JOB_ID);
+
+create table GROUP_ATTENDEE_RECONCILE_WORK (
+  WORK_ID                       integer      primary key default nextval('WORKITEM_SEQ') not null, -- implicit index
+  JOB_ID                        integer      references JOB not null,
+  RESOURCE_ID                   integer,
+  GROUP_ID                      integer
+);
+
+create index GROUP_ATTENDEE_RECONCILE_WORK_JOB_ID on
+  GROUP_ATTENDEE_RECONCILE_WORK(JOB_ID);
+
+
+create table GROUPS (
+  GROUP_ID                      integer      primary key default nextval('RESOURCE_ID_SEQ'),    -- implicit index
+  NAME                          varchar(255) not null,
+  GROUP_UID                     varchar(255) not null,
+  MEMBERSHIP_HASH               varchar(255) not null,
+  EXTANT                        integer default 1,
+  CREATED                       timestamp default timezone('UTC', CURRENT_TIMESTAMP),
+  MODIFIED                      timestamp default timezone('UTC', CURRENT_TIMESTAMP)
+);
+create index GROUPS_GROUP_UID on
+  GROUPS(GROUP_UID);
+
+create table GROUP_MEMBERSHIP (
+  GROUP_ID                     integer not null references GROUPS on delete cascade,
+  MEMBER_UID                   varchar(255) not null,
+  
+  primary key (GROUP_ID, MEMBER_UID)
+);
+
+create index GROUP_MEMBERSHIP_MEMBER on
+  GROUP_MEMBERSHIP(MEMBER_UID);
+
+create table GROUP_ATTENDEE (
+  GROUP_ID                      integer not null references GROUPS on delete cascade,
+  RESOURCE_ID                   integer not null references CALENDAR_OBJECT on delete cascade,
+  MEMBERSHIP_HASH               varchar(255) not null,
+  
+  primary key (GROUP_ID, RESOURCE_ID)
+);
+create index GROUP_ATTENDEE_RESOURCE_ID on
+  GROUP_ATTENDEE(RESOURCE_ID);
+
+---------------
+-- Delegates --
+---------------
+
+create table DELEGATES (
+  DELEGATOR                     varchar(255) not null,
+  DELEGATE                      varchar(255) not null,
+  READ_WRITE                    integer      not null, -- 1 = ReadWrite, 0 = ReadOnly
+
+  primary key (DELEGATOR, READ_WRITE, DELEGATE)
+);
+create index DELEGATE_TO_DELEGATOR on
+  DELEGATES(DELEGATE, READ_WRITE, DELEGATOR);
+
+create table DELEGATE_GROUPS (
+  DELEGATOR                     varchar(255) not null,
+  GROUP_ID                      integer      not null references GROUPS on delete cascade,
+  READ_WRITE                    integer      not null, -- 1 = ReadWrite, 0 = ReadOnly
+  IS_EXTERNAL                   integer      not null, -- 1 = ReadWrite, 0 = ReadOnly
+
+  primary key (DELEGATOR, READ_WRITE, GROUP_ID)
+);
+create index DELEGATE_GROUPS_GROUP_ID on
+  DELEGATE_GROUPS(GROUP_ID);
+
+create table EXTERNAL_DELEGATE_GROUPS (
+  DELEGATOR                     varchar(255) primary key not null,
+  GROUP_UID_READ                varchar(255),
+  GROUP_UID_WRITE               varchar(255)
+);
+
+--------------------------
+-- Object Splitter Work --
+--------------------------
+
+create table CALENDAR_OBJECT_SPLITTER_WORK (
+  WORK_ID                       integer      primary key default nextval('WORKITEM_SEQ') not null, -- implicit index
+  JOB_ID                        integer      references JOB not null,
+  RESOURCE_ID                   integer      not null references CALENDAR_OBJECT on delete cascade
+);
+
+create index CALENDAR_OBJECT_SPLITTER_WORK_RESOURCE_ID on
+  CALENDAR_OBJECT_SPLITTER_WORK(RESOURCE_ID);
+create index CALENDAR_OBJECT_SPLITTER_WORK_JOB_ID on
+  CALENDAR_OBJECT_SPLITTER_WORK(JOB_ID);
+
+---------------------------
+-- Revision Cleanup Work --
+---------------------------
+
+create table FIND_MIN_VALID_REVISION_WORK (
+  WORK_ID                       integer      primary key default nextval('WORKITEM_SEQ') not null, -- implicit index
+  JOB_ID                        integer      references JOB not null
+);
+
+create index FIND_MIN_VALID_REVISION_WORK_JOB_ID on
+  FIND_MIN_VALID_REVISION_WORK(JOB_ID);
+
+create table REVISION_CLEANUP_WORK (
+  WORK_ID                       integer      primary key default nextval('WORKITEM_SEQ') not null, -- implicit index
+  JOB_ID                        integer      references JOB not null
+);
+
+create index REVISION_CLEANUP_WORK_JOB_ID on
+  REVISION_CLEANUP_WORK(JOB_ID);
+
+------------------------
+-- Inbox Cleanup Work --
+------------------------
+
+create table INBOX_CLEANUP_WORK (
+  WORK_ID                       integer      primary key default nextval('WORKITEM_SEQ') not null, -- implicit index
+  JOB_ID                        integer      references JOB not null
+);
+
+create index INBOX_CLEANUP_WORK_JOB_ID on
+   INBOX_CLEANUP_WORK(JOB_ID);
+
+create table CLEANUP_ONE_INBOX_WORK (
+  WORK_ID                       integer      primary key default nextval('WORKITEM_SEQ') not null, -- implicit index
+  JOB_ID                        integer      references JOB not null,
+  HOME_ID                       integer      not null unique references CALENDAR_HOME on delete cascade
+);
+
+create index CLEANUP_ONE_INBOX_WORK_JOB_ID on
+  CLEANUP_ONE_INBOX_WORK(JOB_ID);
+
+-------------------
+-- Schedule Work --
+-------------------
+
+create table SCHEDULE_WORK (
+  WORK_ID                       integer      primary key default nextval('WORKITEM_SEQ') not null, -- implicit index
+  JOB_ID                        integer      references JOB not null,
+  ICALENDAR_UID                 varchar(255) not null,
+  WORK_TYPE                     varchar(255) not null
+);
+
+create index SCHEDULE_WORK_JOB_ID on
+  SCHEDULE_WORK(JOB_ID);
+create index SCHEDULE_WORK_ICALENDAR_UID on
+  SCHEDULE_WORK(ICALENDAR_UID);
+
+---------------------------
+-- Schedule Refresh Work --
+---------------------------
+
+create table SCHEDULE_REFRESH_WORK (
+  WORK_ID                       integer      primary key references SCHEDULE_WORK on delete cascade, -- implicit index
+  HOME_RESOURCE_ID              integer      not null references CALENDAR_HOME on delete cascade,
+  RESOURCE_ID                   integer      not null references CALENDAR_OBJECT on delete cascade,
+  ATTENDEE_COUNT                integer
+);
+
+create index SCHEDULE_REFRESH_WORK_HOME_RESOURCE_ID on
+  SCHEDULE_REFRESH_WORK(HOME_RESOURCE_ID);
+create index SCHEDULE_REFRESH_WORK_RESOURCE_ID on
+  SCHEDULE_REFRESH_WORK(RESOURCE_ID);
+
+create table SCHEDULE_REFRESH_ATTENDEES (
+  RESOURCE_ID                   integer      not null references CALENDAR_OBJECT on delete cascade,
+  ATTENDEE                      varchar(255) not null,
+  
+  primary key (RESOURCE_ID, ATTENDEE)
+);
+
+create index SCHEDULE_REFRESH_ATTENDEES_RESOURCE_ID_ATTENDEE on
+  SCHEDULE_REFRESH_ATTENDEES(RESOURCE_ID, ATTENDEE);
+
+------------------------------
+-- Schedule Auto Reply Work --
+------------------------------
+
+create table SCHEDULE_AUTO_REPLY_WORK (
+  WORK_ID                       integer      primary key references SCHEDULE_WORK on delete cascade, -- implicit index
+  HOME_RESOURCE_ID              integer      not null references CALENDAR_HOME on delete cascade,
+  RESOURCE_ID                   integer      not null references CALENDAR_OBJECT on delete cascade,
+  PARTSTAT                      varchar(255) not null
+);
+
+create index SCHEDULE_AUTO_REPLY_WORK_HOME_RESOURCE_ID on
+  SCHEDULE_AUTO_REPLY_WORK(HOME_RESOURCE_ID);
+create index SCHEDULE_AUTO_REPLY_WORK_RESOURCE_ID on
+  SCHEDULE_AUTO_REPLY_WORK(RESOURCE_ID);
+
+-----------------------------
+-- Schedule Organizer Work --
+-----------------------------
+
+create table SCHEDULE_ORGANIZER_WORK (
+  WORK_ID                       integer      primary key references SCHEDULE_WORK on delete cascade, -- implicit index
+  SCHEDULE_ACTION               integer      not null, -- Enum SCHEDULE_ACTION
+  HOME_RESOURCE_ID              integer      not null references CALENDAR_HOME on delete cascade,
+  RESOURCE_ID                   integer,     -- this references a possibly non-existent CALENDR_OBJECT
+  ICALENDAR_TEXT_OLD            text,
+  ICALENDAR_TEXT_NEW            text,
+  ATTENDEE_COUNT                integer,
+  SMART_MERGE                   boolean
+);
+
+create index SCHEDULE_ORGANIZER_WORK_HOME_RESOURCE_ID on
+  SCHEDULE_ORGANIZER_WORK(HOME_RESOURCE_ID);
+create index SCHEDULE_ORGANIZER_WORK_RESOURCE_ID on
+  SCHEDULE_ORGANIZER_WORK(RESOURCE_ID);
+
+-- Enumeration of schedule actions
+
+create table SCHEDULE_ACTION (
+  ID          integer     primary key,
+  DESCRIPTION varchar(16) not null unique
+);
+
+insert into SCHEDULE_ACTION values (0, 'create');
+insert into SCHEDULE_ACTION values (1, 'modify');
+insert into SCHEDULE_ACTION values (2, 'modify-cancelled');
+insert into SCHEDULE_ACTION values (3, 'remove');
+
+----------------------------------
+-- Schedule Organizer Send Work --
+----------------------------------
+
+create table SCHEDULE_ORGANIZER_SEND_WORK (
+  WORK_ID                       integer      primary key references SCHEDULE_WORK on delete cascade, -- implicit index
+  SCHEDULE_ACTION               integer      not null, -- Enum SCHEDULE_ACTION
+  HOME_RESOURCE_ID              integer      not null references CALENDAR_HOME on delete cascade,
+  RESOURCE_ID                   integer,     -- this references a possibly non-existent CALENDAR_OBJECT
+  ATTENDEE                      varchar(255) not null,
+  ITIP_MSG                      text,
+  NO_REFRESH                    boolean
+);
+
+create index SCHEDULE_ORGANIZER_SEND_WORK_HOME_RESOURCE_ID on
+  SCHEDULE_ORGANIZER_SEND_WORK(HOME_RESOURCE_ID);
+create index SCHEDULE_ORGANIZER_SEND_WORK_RESOURCE_ID on
+  SCHEDULE_ORGANIZER_SEND_WORK(RESOURCE_ID);
+
+-------------------------
+-- Schedule Reply Work --
+-------------------------
+
+create table SCHEDULE_REPLY_WORK (
+  WORK_ID                       integer      primary key references SCHEDULE_WORK on delete cascade, -- implicit index
+  HOME_RESOURCE_ID              integer      not null references CALENDAR_HOME on delete cascade,
+  RESOURCE_ID                   integer      not null references CALENDAR_OBJECT on delete cascade,
+  CHANGED_RIDS                  text
+);
+
+create index SCHEDULE_REPLY_WORK_HOME_RESOURCE_ID on
+  SCHEDULE_REPLY_WORK(HOME_RESOURCE_ID);
+create index SCHEDULE_REPLY_WORK_RESOURCE_ID on
+  SCHEDULE_REPLY_WORK(RESOURCE_ID);
+
+--------------------------------
+-- Schedule Reply Cancel Work --
+--------------------------------
+
+create table SCHEDULE_REPLY_CANCEL_WORK (
+  WORK_ID                       integer      primary key references SCHEDULE_WORK on delete cascade, -- implicit index
+  HOME_RESOURCE_ID              integer      not null references CALENDAR_HOME on delete cascade,
+  ICALENDAR_TEXT                text         not null
+);
+
+create index SCHEDULE_REPLY_CANCEL_WORK_HOME_RESOURCE_ID on
+  SCHEDULE_REPLY_CANCEL_WORK(HOME_RESOURCE_ID);
+
+----------------------------------
+-- Principal Purge Polling Work --
+----------------------------------
+
+create table PRINCIPAL_PURGE_POLLING_WORK (
+  WORK_ID                       integer      primary key default nextval('WORKITEM_SEQ') not null, -- implicit index
+  JOB_ID                        integer      references JOB not null
+);
+
+create index PRINCIPAL_PURGE_POLLING_WORK_JOB_ID on
+  PRINCIPAL_PURGE_POLLING_WORK(JOB_ID);
+
+--------------------------------
+-- Principal Purge Check Work --
+--------------------------------
+
+create table PRINCIPAL_PURGE_CHECK_WORK (
+  WORK_ID                       integer      primary key default nextval('WORKITEM_SEQ') not null, -- implicit index
+  JOB_ID                        integer      references JOB not null,
+  UID                           varchar(255) not null
+);
+
+create index PRINCIPAL_PURGE_CHECK_WORK_JOB_ID on
+  PRINCIPAL_PURGE_CHECK_WORK(JOB_ID);
+
+--------------------------
+-- Principal Purge Work --
+--------------------------
+
+create table PRINCIPAL_PURGE_WORK (
+  WORK_ID                       integer      primary key default nextval('WORKITEM_SEQ') not null, -- implicit index
+  JOB_ID                        integer      references JOB not null,
+  UID                           varchar(255) not null
+);
+
+create index PRINCIPAL_PURGE_WORK_JOB_ID on
+  PRINCIPAL_PURGE_WORK(JOB_ID);
+
+
+--------------------------------
+-- Principal Home Remove Work --
+--------------------------------
+
+create table PRINCIPAL_PURGE_HOME_WORK (
+  WORK_ID                       integer      primary key default nextval('WORKITEM_SEQ') not null, -- implicit index
+  JOB_ID                        integer      references JOB not null,
+  HOME_RESOURCE_ID              integer      not null references CALENDAR_HOME on delete cascade
+);
+
+create index PRINCIPAL_PURGE_HOME_WORK_JOB_ID on
+  PRINCIPAL_PURGE_HOME_WORK(JOB_ID);
+create index PRINCIPAL_PURGE_HOME_HOME_RESOURCE_ID on
+  PRINCIPAL_PURGE_HOME_WORK(HOME_RESOURCE_ID);
+
+
+--------------------
+-- Schema Version --
+--------------------
+
+create table CALENDARSERVER (
+  NAME                          varchar(255) primary key, -- implicit index
+  VALUE                         varchar(255)
+);
+
+insert into CALENDARSERVER values ('VERSION', '45');
+insert into CALENDARSERVER values ('CALENDAR-DATAVERSION', '6');
+insert into CALENDARSERVER values ('ADDRESSBOOK-DATAVERSION', '2');
+insert into CALENDARSERVER values ('NOTIFICATION-DATAVERSION', '1');
+insert into CALENDARSERVER values ('MIN-VALID-REVISION', '1');
</ins></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoresql_schemaupgradesoracledialectupgrade_from_45_to_46sqlfromrev13773CalendarServerbranchesusersgayagroupsharee2txdavcommondatastoresql_schemaupgradesoracledialectupgrade_from_45_to_46sql"></a>
<div class="copfile"><h4>Copied: CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_45_to_46.sql (from rev 13773, CalendarServer/branches/users/gaya/groupsharee2/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_45_to_46.sql) (0 => 13775)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_45_to_46.sql                                (rev 0)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_45_to_46.sql        2014-07-17 21:54:34 UTC (rev 13775)
</span><span class="lines">@@ -0,0 +1,84 @@
</span><ins>+----
+-- Copyright (c) 2012-2014 Apple Inc. All rights reserved.
+--
+-- Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
+-- 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 &quot;AS IS&quot; 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.
+----
+
+---------------------------------------------------
+-- Upgrade database schema from VERSION 45 to 46 --
+---------------------------------------------------
+
+
+-- delete data and add contraint to GROUP_ATTENDEE_RECONCILE_WORK
+
+drop table GROUP_ATTENDEE_RECONCILE_WORK;
+
+create table GROUP_ATTENDEE_RECONCILE_WORK (
+  WORK_ID                       integer primary key default nextval('WORKITEM_SEQ') not null, -- implicit index
+  JOB_ID                        integer not null references JOB,
+  RESOURCE_ID                   integer not null references CALENDAR_OBJECT on delete cascade,
+  GROUP_ID                      integer not null references GROUPS on delete cascade
+);
+
+create index GROUP_ATTENDEE_RECONCILE_WORK_JOB_ID on GROUP_ATTENDEE_RECONCILE_WORK(
+        JOB_ID
+);
+create index GROUP_ATTENDEE_RECONCILE_WORK_RESOURCE_ID on GROUP_ATTENDEE_RECONCILE_WORK(
+        RESOURCE_ID
+);
+create index GROUP_ATTENDEE_RECONCILE_WORK_GROUP_ID on GROUP_ATTENDEE_RECONCILE_WORK(
+        GROUP_ID
+);
+
+  
+-- schema for group sharees
+
+insert into CALENDAR_BIND_MODE (DESCRIPTION, ID) values ('group', 5);
+insert into CALENDAR_BIND_MODE (DESCRIPTION, ID) values ('group_read', 6);
+insert into CALENDAR_BIND_MODE (DESCRIPTION, ID) values ('group_write', 7);
+
+
+create table GROUP_SHAREE_RECONCILE_WORK (
+  WORK_ID                       integer primary key default nextval('WORKITEM_SEQ') not null, -- implicit index
+  JOB_ID                        integer not null references JOB,
+  CALENDAR_ID                   integer        not null references CALENDAR on delete cascade,
+  GROUP_ID                      integer not null references GROUPS on delete cascade
+);
+
+create index GROUP_SHAREE_RECONCILE_WORK_JOB_ID on GROUP_SHAREE_RECONCILE_WORK(
+        JOB_ID
+);
+create index GROUP_SHAREE_RECONCILE_WORK_CALENDAR_ID on GROUP_SHAREE_RECONCILE_WORK(
+        CALENDAR_ID
+);
+create index GROUP_SHAREE_RECONCILE_WORK_GROUP_ID on GROUP_SHAREE_RECONCILE_WORK(
+        GROUP_ID
+);
+
+
+create table GROUP_SHAREE (
+  GROUP_ID                      integer not null references GROUPS on delete cascade,
+  CALENDAR_ID                                      integer not null references CALENDAR on delete cascade,
+  GROUP_BIND_MODE               integer not null, -- enum CALENDAR_BIND_MODE
+  MEMBERSHIP_HASH               varchar(255) not null,
+  
+  primary key (GROUP_ID, CALENDAR_ID) -- implicit index
+);
+
+create index GROUP_SHAREE_CALENDAR_ID on GROUP_SHAREE(
+        CALENDAR_ID
+);
+
+
+-- update the version
+update CALENDARSERVER set VALUE = '46' where NAME = 'VERSION';
</ins></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoresql_schemaupgradespostgresdialectupgrade_from_45_to_46sqlfromrev13773CalendarServerbranchesusersgayagroupsharee2txdavcommondatastoresql_schemaupgradespostgresdialectupgrade_from_45_to_46sql"></a>
<div class="copfile"><h4>Copied: CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/postgres-dialect/upgrade_from_45_to_46.sql (from rev 13773, CalendarServer/branches/users/gaya/groupsharee2/txdav/common/datastore/sql_schema/upgrades/postgres-dialect/upgrade_from_45_to_46.sql) (0 => 13775)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/postgres-dialect/upgrade_from_45_to_46.sql                                (rev 0)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/postgres-dialect/upgrade_from_45_to_46.sql        2014-07-17 21:54:34 UTC (rev 13775)
</span><span class="lines">@@ -0,0 +1,77 @@
</span><ins>+----
+-- Copyright (c) 2012-2014 Apple Inc. All rights reserved.
+--
+-- Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
+-- 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 &quot;AS IS&quot; 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.
+----
+
+---------------------------------------------------
+-- Upgrade database schema from VERSION 45 to 46 --
+---------------------------------------------------
+
+
+-- delete data and add contraint to GROUP_ATTENDEE_RECONCILE_WORK
+
+drop table GROUP_ATTENDEE_RECONCILE_WORK;
+
+create table GROUP_ATTENDEE_RECONCILE_WORK (
+  WORK_ID                       integer primary key default nextval('WORKITEM_SEQ') not null, -- implicit index
+  JOB_ID                        integer not null references JOB,
+  RESOURCE_ID                   integer not null references CALENDAR_OBJECT on delete cascade,
+  GROUP_ID                      integer not null references GROUPS on delete cascade
+);
+
+create index GROUP_ATTENDEE_RECONCILE_WORK_JOB_ID on
+  GROUP_ATTENDEE_RECONCILE_WORK(JOB_ID);
+create index GROUP_ATTENDEE_RECONCILE_WORK_RESOURCE_ID on
+  GROUP_ATTENDEE_RECONCILE_WORK(RESOURCE_ID);
+create index GROUP_ATTENDEE_RECONCILE_WORK_GROUP_ID on
+  GROUP_ATTENDEE_RECONCILE_WORK(GROUP_ID);
+
+  
+-- schema for group sharees
+
+insert into CALENDAR_BIND_MODE values (5, 'group');
+insert into CALENDAR_BIND_MODE values (6, 'group_read');
+insert into CALENDAR_BIND_MODE values (7, 'group_write');
+
+
+create table GROUP_SHAREE_RECONCILE_WORK (
+  WORK_ID                       integer primary key default nextval('WORKITEM_SEQ') not null, -- implicit index
+  JOB_ID                        integer not null references JOB,
+  CALENDAR_ID                   integer        not null references CALENDAR on delete cascade,
+  GROUP_ID                      integer not null references GROUPS on delete cascade
+);
+
+create index GROUP_SHAREE_RECONCILE_WORK_JOB_ID on
+  GROUP_SHAREE_RECONCILE_WORK(JOB_ID);
+create index GROUP_SHAREE_RECONCILE_WORK_CALENDAR_ID on
+  GROUP_SHAREE_RECONCILE_WORK(CALENDAR_ID);
+create index GROUP_SHAREE_RECONCILE_WORK_GROUP_ID on
+  GROUP_SHAREE_RECONCILE_WORK(GROUP_ID);
+
+
+create table GROUP_SHAREE (
+  GROUP_ID                      integer not null references GROUPS on delete cascade,
+  CALENDAR_ID                                      integer not null references CALENDAR on delete cascade,
+  GROUP_BIND_MODE               integer not null, -- enum CALENDAR_BIND_MODE
+  MEMBERSHIP_HASH               varchar(255) not null,
+  
+  primary key (GROUP_ID, CALENDAR_ID) -- implicit index
+);
+
+create index GROUP_SHAREE_CALENDAR_ID on
+  GROUP_SHAREE(CALENDAR_ID);
+
+  
+-- update the version
+update CALENDARSERVER set VALUE = '46' where NAME = 'VERSION';
</ins></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoresql_tablespy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/sql_tables.py (13774 => 13775)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/sql_tables.py        2014-07-17 19:55:36 UTC (rev 13774)
+++ CalendarServer/trunk/txdav/common/datastore/sql_tables.py        2014-07-17 21:54:34 UTC (rev 13775)
</span><span class="lines">@@ -230,6 +230,9 @@
</span><span class="cx"> _BIND_MODE_WRITE = _bindMode('write')
</span><span class="cx"> _BIND_MODE_DIRECT = _bindMode('direct')
</span><span class="cx"> _BIND_MODE_INDIRECT = _bindMode('indirect')
</span><ins>+_BIND_MODE_GROUP = _bindMode('group')
+_BIND_MODE_GROUP_READ = _bindMode('group_read')
+_BIND_MODE_GROUP_WRITE = _bindMode('group_write')
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> _addressBookObjectKind = _schemaConstants(
</span></span></pre></div>
<a id="CalendarServertrunktxdavcommondatastoreworktesttest_revision_cleanuppy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/common/datastore/work/test/test_revision_cleanup.py (13774 => 13775)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/common/datastore/work/test/test_revision_cleanup.py        2014-07-17 19:55:36 UTC (rev 13774)
+++ CalendarServer/trunk/txdav/common/datastore/work/test/test_revision_cleanup.py        2014-07-17 21:54:34 UTC (rev 13775)
</span><span class="lines">@@ -223,7 +223,7 @@
</span><span class="cx">         invites = yield calendar.sharingInvites()
</span><span class="cx">         self.assertEqual(len(invites), 0)
</span><span class="cx"> 
</span><del>-        shareeView = yield calendar.inviteUserToShare(&quot;user02&quot;, _BIND_MODE_READ, &quot;summary&quot;)
</del><ins>+        shareeView = yield calendar.inviteUIDToShare(&quot;user02&quot;, _BIND_MODE_READ, &quot;summary&quot;)
</ins><span class="cx">         inviteUID = shareeView.shareUID()
</span><span class="cx">         yield self.commit()
</span><span class="cx"> 
</span></span></pre></div>
<a id="CalendarServertrunktxdavwhoaugmentpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/who/augment.py (13774 => 13775)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/who/augment.py        2014-07-17 19:55:36 UTC (rev 13774)
+++ CalendarServer/trunk/txdav/who/augment.py        2014-07-17 21:54:34 UTC (rev 13775)
</span><span class="lines">@@ -461,12 +461,12 @@
</span><span class="cx">     def groups(self):
</span><span class="cx">         augmented = []
</span><span class="cx"> 
</span><del>-        def _groupsFor(txn):
-            return txn.groupsFor(self.uid)
</del><ins>+        def _groupUIDsFor(txn):
+            return txn.groupUIDsFor(self.uid)
</ins><span class="cx"> 
</span><span class="cx">         groupUIDs = yield self.service._store.inTransaction(
</span><span class="cx">             &quot;AugmentedDirectoryRecord.groups&quot;,
</span><del>-            _groupsFor
</del><ins>+            _groupUIDsFor
</ins><span class="cx">         )
</span><span class="cx"> 
</span><span class="cx">         for groupUID in groupUIDs:
</span></span></pre></div>
<a id="CalendarServertrunktxdavwhogroupspy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/who/groups.py (13774 => 13775)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/who/groups.py        2014-07-17 19:55:36 UTC (rev 13774)
+++ CalendarServer/trunk/txdav/who/groups.py        2014-07-17 21:54:34 UTC (rev 13775)
</span><span class="lines">@@ -29,9 +29,8 @@
</span><span class="cx"> from twistedcaldav.config import config
</span><span class="cx"> from txdav.caldav.datastore.scheduling.icalsplitter import iCalSplitter
</span><span class="cx"> from txdav.caldav.datastore.sql import CalendarStoreFeatures, ComponentUpdateState
</span><del>-from txdav.common.datastore.sql_tables import schema
</del><ins>+from txdav.common.datastore.sql_tables import schema, _BIND_MODE_OWN
</ins><span class="cx"> import datetime
</span><del>-import hashlib
</del><span class="cx"> 
</span><span class="cx"> log = Logger()
</span><span class="cx"> 
</span><span class="lines">@@ -222,6 +221,41 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+class GroupShareeReconciliationWork(
+    WorkItem, fromTable(schema.GROUP_SHAREE_RECONCILE_WORK)
+):
+
+    group = property(
+        lambda self: (self.table.CALENDAR_ID == self.calendarID)
+    )
+
+
+    @inlineCallbacks
+    def doWork(self):
+
+        # Delete all other work items for this event
+        yield Delete(
+            From=self.table,
+            Where=self.group,
+        ).on(self.transaction)
+
+        bind = schema.CALENDAR_BIND
+        rows = yield Select(
+            [bind.HOME_RESOURCE_ID],
+            From=bind,
+            Where=(bind.CALENDAR_RESOURCE_ID == self.calendarID).And(
+                bind.BIND_MODE == _BIND_MODE_OWN
+            ),
+        ).on(self.transaction)
+        if rows:
+            homeID = rows[0][0]
+            home = yield self.transaction.calendarHomeWithResourceID(homeID)
+            calendar = yield home.childWithID(self.calendarID)
+            groupUID = ((yield self.transaction.groupByID(self.groupID)))[0]
+            yield calendar.reconcileGroupSharee(groupUID)
+
+
+
</ins><span class="cx"> def diffAssignments(old, new):
</span><span class="cx">     &quot;&quot;&quot;
</span><span class="cx">     Compare two proxy assignment lists and return their differences in the form
</span><span class="lines">@@ -315,14 +349,14 @@
</span><span class="cx">                 readDelegateGroupID = writeDelegateGroupID = None
</span><span class="cx">                 if readDelegateUID:
</span><span class="cx">                     (
</span><del>-                        readDelegateGroupID, _ignore_name, hash,
</del><ins>+                        readDelegateGroupID, _ignore_name, _ignore_hash,
</ins><span class="cx">                         _ignore_modified, _ignore_extant
</span><span class="cx">                     ) = (
</span><span class="cx">                         yield txn.groupByUID(readDelegateUID)
</span><span class="cx">                     )
</span><span class="cx">                 if writeDelegateUID:
</span><span class="cx">                     (
</span><del>-                        writeDelegateGroupID, _ignore_name, hash,
</del><ins>+                        writeDelegateGroupID, _ignore_name, _ignore_hash,
</ins><span class="cx">                         _ignore_modified, _ignore_extant
</span><span class="cx">                     ) = (
</span><span class="cx">                         yield txn.groupByUID(writeDelegateUID)
</span><span class="lines">@@ -346,106 +380,36 @@
</span><span class="cx">             and updates the GROUP_MEMBERSHIP table
</span><span class="cx">             WorkProposal is returned for tests
</span><span class="cx">         &quot;&quot;&quot;
</span><del>-        self.log.debug(&quot;Faulting in group: {g}&quot;, g=groupUID)
-        record = (yield self.directory.recordWithUID(groupUID))
-        if record is None:
-            # the group has disappeared from the directory
-            self.log.info(&quot;Group is missing: {g}&quot;, g=groupUID)
-        else:
-            self.log.debug(&quot;Got group record: {u}&quot;, u=record.uid)
</del><ins>+        groupID, membershipChanged = yield txn.refreshGroup(groupUID)
</ins><span class="cx"> 
</span><del>-        (
-            groupID, cachedName, cachedMembershipHash, _ignore_modified,
-            extant
-        ) = yield txn.groupByUID(
-            groupUID,
-            create=(record is not None)
-        )
</del><ins>+        if membershipChanged:
+            wpsAttendee = yield self.scheduleGroupAttendeeReconciliations(txn, groupID)
+            wpsShareee = yield self.scheduleGroupShareeReconciliations(txn, groupID)
+            returnValue(wpsAttendee + wpsShareee)
</ins><span class="cx"> 
</span><del>-        wps = tuple()
-        if groupID:
-            if record is not None:
-                members = yield record.expandedMembers()
-                name = record.displayName
-                extant = True
-            else:
-                members = frozenset()
-                name = cachedName
-                extant = False
</del><ins>+        returnValue(tuple())
</ins><span class="cx"> 
</span><del>-            membershipHashContent = hashlib.md5()
-            members = list(members)
-            members.sort(key=lambda x: x.uid)
-            for member in members:
-                membershipHashContent.update(str(member.uid))
-            membershipHash = membershipHashContent.hexdigest()
</del><span class="cx"> 
</span><del>-            if cachedMembershipHash != membershipHash:
-                membershipChanged = True
-                self.log.debug(
-                    &quot;Group '{group}' changed&quot;, group=name
-                )
-            else:
-                membershipChanged = False
-
-            if membershipChanged or record is not None:
-                # also updates group mod date
-                yield txn.updateGroup(
-                    groupUID, name, membershipHash, extant=extant
-                )
-
-            if membershipChanged:
-                newMemberUIDs = set()
-                for member in members:
-                    newMemberUIDs.add(member.uid)
-                yield self.synchronizeMembers(txn, groupID, newMemberUIDs)
-
-                wps = yield self.scheduleEventReconciliations(txn, groupID)
-
-        returnValue(wps)
-
-
-    @inlineCallbacks
</del><span class="cx">     def synchronizeMembers(self, txn, groupID, newMemberUIDs):
</span><del>-        numRemoved = numAdded = 0
-        cachedMemberUIDs = (yield txn.membersOfGroup(groupID))
</del><ins>+        return txn.synchronizeMembers(groupID, newMemberUIDs)
</ins><span class="cx"> 
</span><del>-        for memberUID in cachedMemberUIDs:
-            if memberUID not in newMemberUIDs:
-                numRemoved += 1
-                yield txn.removeMemberFromGroup(memberUID, groupID)
</del><span class="cx"> 
</span><del>-        for memberUID in newMemberUIDs:
-            if memberUID not in cachedMemberUIDs:
-                numAdded += 1
-                yield txn.addMemberToGroup(memberUID, groupID)
-
-        returnValue((numAdded, numRemoved))
-
-
-    @inlineCallbacks
</del><span class="cx">     def cachedMembers(self, txn, groupID):
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         The members of the given group as recorded in the db
</span><span class="cx">         &quot;&quot;&quot;
</span><del>-        members = set()
-        memberUIDs = (yield txn.membersOfGroup(groupID))
-        for uid in memberUIDs:
-            record = (yield self.directory.recordWithUID(uid))
-            if record is not None:
-                members.add(record)
-        returnValue(members)
</del><ins>+        return txn.groupMembers(groupID)
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     def cachedGroupsFor(self, txn, uid):
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         The UIDs of the groups the uid is a member of
</span><span class="cx">         &quot;&quot;&quot;
</span><del>-        return txn.groupsFor(uid)
</del><ins>+        return txn.groupUIDsFor(uid)
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><del>-    def scheduleEventReconciliations(self, txn, groupID):
</del><ins>+    def scheduleGroupAttendeeReconciliations(self, txn, groupID):
</ins><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         Find all events who have this groupID as an attendee and create
</span><span class="cx">         work items for them.
</span><span class="lines">@@ -471,6 +435,32 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><ins>+    def scheduleGroupShareeReconciliations(self, txn, groupID):
+        &quot;&quot;&quot;
+        Find all calendars who have shared to this groupID and create
+        work items for them.
+        returns: WorkProposal
+        &quot;&quot;&quot;
+        gs = schema.GROUP_SHAREE
+        rows = yield Select(
+            [gs.CALENDAR_ID, ],
+            From=gs,
+            Where=gs.GROUP_ID == groupID,
+        ).on(txn)
+
+        wps = []
+        for [calendarID] in rows:
+            wp = yield GroupShareeReconciliationWork.reschedule(
+                txn,
+                seconds=float(config.Sharing.Calendars.Groups.ReconciliationDelaySeconds),
+                calendarID=calendarID,
+                groupID=groupID,
+            )
+            wps.append(wp)
+        returnValue(tuple(wps))
+
+
+    @inlineCallbacks
</ins><span class="cx">     def groupsToRefresh(self, txn):
</span><span class="cx">         delegatedUIDs = set((yield txn.allGroupDelegates()))
</span><span class="cx">         self.log.info(
</span><span class="lines">@@ -478,15 +468,15 @@
</span><span class="cx">         )
</span><span class="cx"> 
</span><span class="cx">         # Get groupUIDs for all group attendees
</span><del>-        groupAttendee = schema.GROUP_ATTENDEE
</del><ins>+        ga = schema.GROUP_ATTENDEE
</ins><span class="cx">         gr = schema.GROUPS
</span><span class="cx">         rows = yield Select(
</span><span class="cx">             [gr.GROUP_UID],
</span><span class="cx">             From=gr,
</span><span class="cx">             Where=gr.GROUP_ID.In(
</span><span class="cx">                 Select(
</span><del>-                    [groupAttendee.GROUP_ID],
-                    From=groupAttendee,
</del><ins>+                    [ga.GROUP_ID],
+                    From=ga,
</ins><span class="cx">                     Distinct=True
</span><span class="cx">                 )
</span><span class="cx">             )
</span><span class="lines">@@ -496,6 +486,25 @@
</span><span class="cx">             &quot;There are {count} group attendees&quot;, count=len(attendeeGroupUIDs)
</span><span class="cx">         )
</span><span class="cx"> 
</span><ins>+        # Get groupUIDs for all group shares
+        gs = schema.GROUP_SHAREE
+        gr = schema.GROUPS
+        rows = yield Select(
+            [gr.GROUP_UID],
+            From=gr,
+            Where=gr.GROUP_ID.In(
+                Select(
+                    [gs.GROUP_ID],
+                    From=gs,
+                    Distinct=True
+                )
+            )
+        ).on(txn)
+        shareeGroupUIDs = set([row[0] for row in rows])
+        self.log.info(
+            &quot;There are {count} group sharees&quot;, count=len(shareeGroupUIDs)
+        )
+
</ins><span class="cx">         # FIXME: is this a good place to clear out unreferenced groups?
</span><span class="cx"> 
</span><del>-        returnValue(delegatedUIDs.union(attendeeGroupUIDs))
</del><ins>+        returnValue(frozenset(delegatedUIDs | attendeeGroupUIDs | shareeGroupUIDs))
</ins></span></pre></div>
<a id="CalendarServertrunktxdavwhotestaccountsgroupAccountsxmlfromrev13773CalendarServerbranchesusersgayagroupsharee2txdavwhotestaccountsgroupAccountsxml"></a>
<div class="copfile"><h4>Copied: CalendarServer/trunk/txdav/who/test/accounts/groupAccounts.xml (from rev 13773, CalendarServer/branches/users/gaya/groupsharee2/txdav/who/test/accounts/groupAccounts.xml) (0 => 13775)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/who/test/accounts/groupAccounts.xml                                (rev 0)
+++ CalendarServer/trunk/txdav/who/test/accounts/groupAccounts.xml        2014-07-17 21:54:34 UTC (rev 13775)
</span><span class="lines">@@ -0,0 +1,139 @@
</span><ins>+&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
+
+&lt;!--
+Copyright (c) 2006-2014 Apple Inc. All rights reserved.
+
+Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
+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 &quot;AS IS&quot; 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.
+ --&gt;
+
+&lt;!DOCTYPE accounts SYSTEM &quot;accounts.dtd&quot;&gt;
+
+&lt;directory realm=&quot;Test Realm&quot;&gt;
+        &lt;record type=&quot;user&quot;&gt;
+            &lt;short-name&gt;user01&lt;/short-name&gt;
+            &lt;uid&gt;user01&lt;/uid&gt;
+            &lt;guid&gt;10000000-0000-0000-0000-000000000001&lt;/guid&gt;
+            &lt;password&gt;user01&lt;/password&gt;
+            &lt;full-name&gt;User 01&lt;/full-name&gt;
+            &lt;email&gt;user01@example.com&lt;/email&gt;
+        &lt;/record&gt;
+        &lt;record type=&quot;user&quot;&gt;
+            &lt;short-name&gt;user02&lt;/short-name&gt;
+            &lt;uid&gt;user02&lt;/uid&gt;
+            &lt;guid&gt;10000000-0000-0000-0000-000000000002&lt;/guid&gt;
+            &lt;password&gt;user02&lt;/password&gt;
+            &lt;full-name&gt;User 02&lt;/full-name&gt;
+            &lt;email&gt;user02@example.com&lt;/email&gt;
+        &lt;/record&gt;
+        &lt;record type=&quot;user&quot;&gt;
+            &lt;short-name&gt;user03&lt;/short-name&gt;
+            &lt;uid&gt;user03&lt;/uid&gt;
+            &lt;guid&gt;10000000-0000-0000-0000-000000000003&lt;/guid&gt;
+            &lt;password&gt;user03&lt;/password&gt;
+            &lt;full-name&gt;User 03&lt;/full-name&gt;
+            &lt;email&gt;user03@example.com&lt;/email&gt;
+        &lt;/record&gt;
+        &lt;record type=&quot;user&quot;&gt;
+            &lt;short-name&gt;user04&lt;/short-name&gt;
+            &lt;uid&gt;user04&lt;/uid&gt;
+            &lt;guid&gt;10000000-0000-0000-0000-000000000004&lt;/guid&gt;
+            &lt;password&gt;user04&lt;/password&gt;
+            &lt;full-name&gt;User 04&lt;/full-name&gt;
+            &lt;email&gt;user04@example.com&lt;/email&gt;
+        &lt;/record&gt;
+        &lt;record type=&quot;user&quot;&gt;
+            &lt;short-name&gt;user05&lt;/short-name&gt;
+            &lt;uid&gt;user05&lt;/uid&gt;
+            &lt;guid&gt;10000000-0000-0000-0000-000000000005&lt;/guid&gt;
+            &lt;password&gt;user05&lt;/password&gt;
+            &lt;full-name&gt;User 05&lt;/full-name&gt;
+            &lt;email&gt;user05@example.com&lt;/email&gt;
+        &lt;/record&gt;
+        &lt;record type=&quot;user&quot;&gt;
+            &lt;short-name&gt;user06&lt;/short-name&gt;
+            &lt;uid&gt;user06&lt;/uid&gt;
+            &lt;guid&gt;10000000-0000-0000-0000-000000000006&lt;/guid&gt;
+            &lt;password&gt;user06&lt;/password&gt;
+            &lt;full-name&gt;User 06&lt;/full-name&gt;
+            &lt;email&gt;user06@example.com&lt;/email&gt;
+        &lt;/record&gt;
+        &lt;record type=&quot;user&quot;&gt;
+            &lt;short-name&gt;user07&lt;/short-name&gt;
+            &lt;uid&gt;user07&lt;/uid&gt;
+            &lt;guid&gt;10000000-0000-0000-0000-000000000007&lt;/guid&gt;
+            &lt;password&gt;user07&lt;/password&gt;
+            &lt;full-name&gt;User 07&lt;/full-name&gt;
+            &lt;email&gt;user07@example.com&lt;/email&gt;
+        &lt;/record&gt;
+        &lt;record type=&quot;user&quot;&gt;
+            &lt;short-name&gt;user08&lt;/short-name&gt;
+            &lt;uid&gt;user08&lt;/uid&gt;
+            &lt;guid&gt;10000000-0000-0000-0000-000000000008&lt;/guid&gt;
+            &lt;password&gt;user08&lt;/password&gt;
+            &lt;full-name&gt;User 08&lt;/full-name&gt;
+            &lt;email&gt;user08@example.com&lt;/email&gt;
+        &lt;/record&gt;
+        &lt;record type=&quot;user&quot;&gt;
+            &lt;short-name&gt;user09&lt;/short-name&gt;
+            &lt;uid&gt;user09&lt;/uid&gt;
+            &lt;guid&gt;10000000-0000-0000-0000-000000000009&lt;/guid&gt;
+            &lt;password&gt;user09&lt;/password&gt;
+            &lt;full-name&gt;User 09&lt;/full-name&gt;
+            &lt;email&gt;user09@example.com&lt;/email&gt;
+        &lt;/record&gt;
+        &lt;record type=&quot;user&quot;&gt;
+            &lt;short-name&gt;user10&lt;/short-name&gt;
+            &lt;uid&gt;user10&lt;/uid&gt;
+            &lt;guid&gt;10000000-0000-0000-0000-000000000010&lt;/guid&gt;
+            &lt;password&gt;user10&lt;/password&gt;
+            &lt;full-name&gt;User 10&lt;/full-name&gt;
+            &lt;email&gt;user10@example.com&lt;/email&gt;
+        &lt;/record&gt;
+        &lt;record type=&quot;group&quot;&gt;
+            &lt;short-name&gt;group01&lt;/short-name&gt;
+            &lt;uid&gt;group01&lt;/uid&gt;
+            &lt;guid&gt;20000000-0000-0000-0000-000000000001&lt;/guid&gt;
+            &lt;full-name&gt;Group 01&lt;/full-name&gt;
+            &lt;email&gt;group01@example.com&lt;/email&gt;
+            &lt;member-uid&gt;user01&lt;/member-uid&gt;
+        &lt;/record&gt;
+        &lt;record type=&quot;group&quot;&gt;
+            &lt;short-name&gt;group02&lt;/short-name&gt;
+            &lt;uid&gt;group02&lt;/uid&gt;
+            &lt;guid&gt;20000000-0000-0000-0000-000000000002&lt;/guid&gt;
+            &lt;full-name&gt;Group 02&lt;/full-name&gt;
+            &lt;email&gt;group02@example.com&lt;/email&gt;
+            &lt;member-uid&gt;user06&lt;/member-uid&gt;
+            &lt;member-uid&gt;user07&lt;/member-uid&gt;
+            &lt;member-uid&gt;user08&lt;/member-uid&gt;
+        &lt;/record&gt;
+        &lt;record type=&quot;group&quot;&gt;
+            &lt;short-name&gt;group03&lt;/short-name&gt;
+            &lt;uid&gt;group03&lt;/uid&gt;
+            &lt;guid&gt;20000000-0000-0000-0000-000000000003&lt;/guid&gt;
+            &lt;full-name&gt;Group 03&lt;/full-name&gt;
+            &lt;email&gt;group03@example.com&lt;/email&gt;
+            &lt;member-uid&gt;user07&lt;/member-uid&gt;
+            &lt;member-uid&gt;user08&lt;/member-uid&gt;
+            &lt;member-uid&gt;user09&lt;/member-uid&gt;
+        &lt;/record&gt;
+        &lt;record type=&quot;group&quot;&gt;
+            &lt;short-name&gt;group04&lt;/short-name&gt;
+            &lt;uid&gt;group04&lt;/uid&gt;
+            &lt;guid&gt;20000000-0000-0000-0000-000000000004&lt;/guid&gt;
+            &lt;full-name&gt;Group 04&lt;/full-name&gt;
+            &lt;member-uid&gt;group02&lt;/member-uid&gt;
+            &lt;member-uid&gt;group03&lt;/member-uid&gt;
+            &lt;member-uid&gt;user10&lt;/member-uid&gt;
+        &lt;/record&gt;
+&lt;/directory&gt;
</ins></span></pre></div>
<a id="CalendarServertrunktxdavwhotestaccountsgroupAttendeeAccountsxml"></a>
<div class="delfile"><h4>Deleted: CalendarServer/trunk/txdav/who/test/accounts/groupAttendeeAccounts.xml (13774 => 13775)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/who/test/accounts/groupAttendeeAccounts.xml        2014-07-17 19:55:36 UTC (rev 13774)
+++ CalendarServer/trunk/txdav/who/test/accounts/groupAttendeeAccounts.xml        2014-07-17 21:54:34 UTC (rev 13775)
</span><span class="lines">@@ -1,139 +0,0 @@
</span><del>-&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
-
-&lt;!--
-Copyright (c) 2006-2014 Apple Inc. All rights reserved.
-
-Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
-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 &quot;AS IS&quot; 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.
- --&gt;
-
-&lt;!DOCTYPE accounts SYSTEM &quot;accounts.dtd&quot;&gt;
-
-&lt;directory realm=&quot;Test Realm&quot;&gt;
-        &lt;record type=&quot;user&quot;&gt;
-            &lt;short-name&gt;user01&lt;/short-name&gt;
-            &lt;uid&gt;10000000-0000-0000-0000-000000000001&lt;/uid&gt;
-            &lt;guid&gt;10000000-0000-0000-0000-000000000001&lt;/guid&gt;
-            &lt;password&gt;user01&lt;/password&gt;
-            &lt;full-name&gt;User 01&lt;/full-name&gt;
-            &lt;email&gt;user01@example.com&lt;/email&gt;
-        &lt;/record&gt;
-        &lt;record type=&quot;user&quot;&gt;
-            &lt;short-name&gt;user02&lt;/short-name&gt;
-            &lt;uid&gt;10000000-0000-0000-0000-000000000002&lt;/uid&gt;
-            &lt;guid&gt;10000000-0000-0000-0000-000000000002&lt;/guid&gt;
-            &lt;password&gt;user02&lt;/password&gt;
-            &lt;full-name&gt;User 02&lt;/full-name&gt;
-            &lt;email&gt;user02@example.com&lt;/email&gt;
-        &lt;/record&gt;
-        &lt;record type=&quot;user&quot;&gt;
-            &lt;short-name&gt;user03&lt;/short-name&gt;
-            &lt;uid&gt;10000000-0000-0000-0000-000000000003&lt;/uid&gt;
-            &lt;guid&gt;10000000-0000-0000-0000-000000000003&lt;/guid&gt;
-            &lt;password&gt;user03&lt;/password&gt;
-            &lt;full-name&gt;User 03&lt;/full-name&gt;
-            &lt;email&gt;user03@example.com&lt;/email&gt;
-        &lt;/record&gt;
-        &lt;record type=&quot;user&quot;&gt;
-            &lt;short-name&gt;user04&lt;/short-name&gt;
-            &lt;uid&gt;10000000-0000-0000-0000-000000000004&lt;/uid&gt;
-            &lt;guid&gt;10000000-0000-0000-0000-000000000004&lt;/guid&gt;
-            &lt;password&gt;user04&lt;/password&gt;
-            &lt;full-name&gt;User 04&lt;/full-name&gt;
-            &lt;email&gt;user04@example.com&lt;/email&gt;
-        &lt;/record&gt;
-        &lt;record type=&quot;user&quot;&gt;
-            &lt;short-name&gt;user05&lt;/short-name&gt;
-            &lt;uid&gt;10000000-0000-0000-0000-000000000005&lt;/uid&gt;
-            &lt;guid&gt;10000000-0000-0000-0000-000000000005&lt;/guid&gt;
-            &lt;password&gt;user05&lt;/password&gt;
-            &lt;full-name&gt;User 05&lt;/full-name&gt;
-            &lt;email&gt;user05@example.com&lt;/email&gt;
-        &lt;/record&gt;
-        &lt;record type=&quot;user&quot;&gt;
-            &lt;short-name&gt;user06&lt;/short-name&gt;
-            &lt;uid&gt;10000000-0000-0000-0000-000000000006&lt;/uid&gt;
-            &lt;guid&gt;10000000-0000-0000-0000-000000000006&lt;/guid&gt;
-            &lt;password&gt;user06&lt;/password&gt;
-            &lt;full-name&gt;User 06&lt;/full-name&gt;
-            &lt;email&gt;user06@example.com&lt;/email&gt;
-        &lt;/record&gt;
-        &lt;record type=&quot;user&quot;&gt;
-            &lt;short-name&gt;user07&lt;/short-name&gt;
-            &lt;uid&gt;10000000-0000-0000-0000-000000000007&lt;/uid&gt;
-            &lt;guid&gt;10000000-0000-0000-0000-000000000007&lt;/guid&gt;
-            &lt;password&gt;user07&lt;/password&gt;
-            &lt;full-name&gt;User 07&lt;/full-name&gt;
-            &lt;email&gt;user07@example.com&lt;/email&gt;
-        &lt;/record&gt;
-        &lt;record type=&quot;user&quot;&gt;
-            &lt;short-name&gt;user08&lt;/short-name&gt;
-            &lt;uid&gt;10000000-0000-0000-0000-000000000008&lt;/uid&gt;
-            &lt;guid&gt;10000000-0000-0000-0000-000000000008&lt;/guid&gt;
-            &lt;password&gt;user08&lt;/password&gt;
-            &lt;full-name&gt;User 08&lt;/full-name&gt;
-            &lt;email&gt;user08@example.com&lt;/email&gt;
-        &lt;/record&gt;
-        &lt;record type=&quot;user&quot;&gt;
-            &lt;short-name&gt;user09&lt;/short-name&gt;
-            &lt;uid&gt;10000000-0000-0000-0000-000000000009&lt;/uid&gt;
-            &lt;guid&gt;10000000-0000-0000-0000-000000000009&lt;/guid&gt;
-            &lt;password&gt;user09&lt;/password&gt;
-            &lt;full-name&gt;User 09&lt;/full-name&gt;
-            &lt;email&gt;user09@example.com&lt;/email&gt;
-        &lt;/record&gt;
-        &lt;record type=&quot;user&quot;&gt;
-            &lt;short-name&gt;user10&lt;/short-name&gt;
-            &lt;uid&gt;10000000-0000-0000-0000-000000000010&lt;/uid&gt;
-            &lt;guid&gt;10000000-0000-0000-0000-000000000010&lt;/guid&gt;
-            &lt;password&gt;user10&lt;/password&gt;
-            &lt;full-name&gt;User 10&lt;/full-name&gt;
-            &lt;email&gt;user10@example.com&lt;/email&gt;
-        &lt;/record&gt;
-        &lt;record type=&quot;group&quot;&gt;
-            &lt;short-name&gt;group01&lt;/short-name&gt;
-            &lt;uid&gt;20000000-0000-0000-0000-000000000001&lt;/uid&gt;
-            &lt;guid&gt;20000000-0000-0000-0000-000000000001&lt;/guid&gt;
-            &lt;full-name&gt;Group 01&lt;/full-name&gt;
-            &lt;email&gt;group01@example.com&lt;/email&gt;
-            &lt;member-uid&gt;10000000-0000-0000-0000-000000000001&lt;/member-uid&gt;
-        &lt;/record&gt;
-        &lt;record type=&quot;group&quot;&gt;
-            &lt;short-name&gt;group02&lt;/short-name&gt;
-            &lt;uid&gt;20000000-0000-0000-0000-000000000002&lt;/uid&gt;
-            &lt;guid&gt;20000000-0000-0000-0000-000000000002&lt;/guid&gt;
-            &lt;full-name&gt;Group 02&lt;/full-name&gt;
-            &lt;email&gt;group02@example.com&lt;/email&gt;
-            &lt;member-uid&gt;10000000-0000-0000-0000-000000000006&lt;/member-uid&gt;
-            &lt;member-uid&gt;10000000-0000-0000-0000-000000000007&lt;/member-uid&gt;
-            &lt;member-uid&gt;10000000-0000-0000-0000-000000000008&lt;/member-uid&gt;
-        &lt;/record&gt;
-        &lt;record type=&quot;group&quot;&gt;
-            &lt;short-name&gt;group03&lt;/short-name&gt;
-            &lt;uid&gt;20000000-0000-0000-0000-000000000003&lt;/uid&gt;
-            &lt;guid&gt;20000000-0000-0000-0000-000000000003&lt;/guid&gt;
-            &lt;full-name&gt;Group 03&lt;/full-name&gt;
-            &lt;email&gt;group03@example.com&lt;/email&gt;
-            &lt;member-uid&gt;10000000-0000-0000-0000-000000000007&lt;/member-uid&gt;
-            &lt;member-uid&gt;10000000-0000-0000-0000-000000000008&lt;/member-uid&gt;
-            &lt;member-uid&gt;10000000-0000-0000-0000-000000000009&lt;/member-uid&gt;
-        &lt;/record&gt;
-        &lt;record type=&quot;group&quot;&gt;
-            &lt;short-name&gt;group04&lt;/short-name&gt;
-            &lt;uid&gt;20000000-0000-0000-0000-000000000004&lt;/uid&gt;
-            &lt;guid&gt;20000000-0000-0000-0000-000000000004&lt;/guid&gt;
-            &lt;full-name&gt;Group 04&lt;/full-name&gt;
-            &lt;member-uid&gt;20000000-0000-0000-0000-000000000002&lt;/member-uid&gt;
-            &lt;member-uid&gt;20000000-0000-0000-0000-000000000003&lt;/member-uid&gt;
-            &lt;member-uid&gt;10000000-0000-0000-0000-000000000010&lt;/member-uid&gt;
-        &lt;/record&gt;
-&lt;/directory&gt;
</del></span></pre></div>
<a id="CalendarServertrunktxdavwhotesttest_group_attendeespy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/who/test/test_group_attendees.py (13774 => 13775)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/who/test/test_group_attendees.py        2014-07-17 19:55:36 UTC (rev 13774)
+++ CalendarServer/trunk/txdav/who/test/test_group_attendees.py        2014-07-17 21:54:34 UTC (rev 13775)
</span><span class="lines">@@ -34,21 +34,20 @@
</span><span class="cx"> import os
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-class GroupAttendeeReconciliation(CommonCommonTests, unittest.TestCase):
</del><ins>+class GroupAttendeeTestBase(CommonCommonTests, unittest.TestCase):
</ins><span class="cx">     &quot;&quot;&quot;
</span><span class="cx">     GroupAttendeeReconciliation tests
</span><span class="cx">     &quot;&quot;&quot;
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><span class="cx">     def setUp(self):
</span><del>-        yield super(GroupAttendeeReconciliation, self).setUp()
</del><ins>+        yield super(GroupAttendeeTestBase, self).setUp()
</ins><span class="cx"> 
</span><span class="cx">         accountsFilePath = FilePath(
</span><span class="cx">             os.path.join(os.path.dirname(__file__), &quot;accounts&quot;)
</span><span class="cx">         )
</span><span class="cx">         yield self.buildStoreAndDirectory(
</span><del>-            accounts=accountsFilePath.child(&quot;groupAttendeeAccounts.xml&quot;),
-            resources=accountsFilePath.child(&quot;resources.xml&quot;),
</del><ins>+            accounts=accountsFilePath.child(&quot;groupAccounts.xml&quot;),
</ins><span class="cx">         )
</span><span class="cx">         yield self.populate()
</span><span class="cx"> 
</span><span class="lines">@@ -56,7 +55,7 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     def configure(self):
</span><del>-        super(GroupAttendeeReconciliation, self).configure()
</del><ins>+        super(GroupAttendeeTestBase, self).configure()
</ins><span class="cx">         config.GroupAttendees.Enabled = True
</span><span class="cx">         config.GroupAttendees.ReconciliationDelaySeconds = 0
</span><span class="cx">         config.GroupAttendees.UpdateOldEventLimitSeconds = 0
</span><span class="lines">@@ -67,13 +66,13 @@
</span><span class="cx">         yield populateCalendarsFrom(self.requirements, self.storeUnderTest())
</span><span class="cx"> 
</span><span class="cx">     requirements = {
</span><del>-        &quot;10000000-0000-0000-0000-000000000001&quot; : None,
-        &quot;10000000-0000-0000-0000-000000000002&quot; : None,
-        &quot;10000000-0000-0000-0000-000000000006&quot; : None,
-        &quot;10000000-0000-0000-0000-000000000007&quot; : None,
-        &quot;10000000-0000-0000-0000-000000000008&quot; : None,
-        &quot;10000000-0000-0000-0000-000000000009&quot; : None,
-        &quot;10000000-0000-0000-0000-000000000010&quot; : None,
</del><ins>+        &quot;user01&quot; : None,
+        &quot;user02&quot; : None,
+        &quot;user06&quot; : None,
+        &quot;user07&quot; : None,
+        &quot;user08&quot; : None,
+        &quot;user09&quot; : None,
+        &quot;user10&quot; : None,
</ins><span class="cx"> 
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -107,12 +106,15 @@
</span><span class="cx">         )
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+
+class GroupAttendeeTests(GroupAttendeeTestBase):
+
</ins><span class="cx">     @inlineCallbacks
</span><span class="cx">     def test_simplePUT(self):
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         Test that group attendee is expanded on PUT
</span><span class="cx">         &quot;&quot;&quot;
</span><del>-        calendar = yield self.calendarUnderTest(name=&quot;calendar&quot;, home=&quot;10000000-0000-0000-0000-000000000001&quot;)
</del><ins>+        calendar = yield self.calendarUnderTest(name=&quot;calendar&quot;, home=&quot;user01&quot;)
</ins><span class="cx"> 
</span><span class="cx">         data_put_1 = &quot;&quot;&quot;BEGIN:VCALENDAR
</span><span class="cx"> CALSCALE:GREGORIAN
</span><span class="lines">@@ -139,31 +141,31 @@
</span><span class="cx"> UID:event1@ninevah.local
</span><span class="cx"> DTSTART:20140101T100000Z
</span><span class="cx"> DURATION:PT1H
</span><del>-ATTENDEE;CN=User 01;EMAIL=user01@example.com;RSVP=TRUE:urn:x-uid:10000000-0000-0000-0000-000000000001
-ATTENDEE;CN=Group 02;CUTYPE=X-SERVER-GROUP;EMAIL=group02@example.com;RSVP=TRUE:urn:x-uid:20000000-0000-0000-0000-000000000002
-ATTENDEE;CN=User 06;EMAIL=user06@example.com;MEMBER=&quot;urn:x-uid:20000000-0000-0000-0000-000000000002&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:10000000-0000-0000-0000-000000000006
-ATTENDEE;CN=User 07;EMAIL=user07@example.com;MEMBER=&quot;urn:x-uid:20000000-0000-0000-0000-000000000002&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:10000000-0000-0000-0000-000000000007
-ATTENDEE;CN=User 08;EMAIL=user08@example.com;MEMBER=&quot;urn:x-uid:20000000-0000-0000-0000-000000000002&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:10000000-0000-0000-0000-000000000008
</del><ins>+ATTENDEE;CN=User 01;EMAIL=user01@example.com;RSVP=TRUE:urn:x-uid:user01
+ATTENDEE;CN=Group 02;CUTYPE=X-SERVER-GROUP;EMAIL=group02@example.com;RSVP=TRUE:urn:x-uid:group02
+ATTENDEE;CN=User 06;EMAIL=user06@example.com;MEMBER=&quot;urn:x-uid:group02&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:user06
+ATTENDEE;CN=User 07;EMAIL=user07@example.com;MEMBER=&quot;urn:x-uid:group02&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:user07
+ATTENDEE;CN=User 08;EMAIL=user08@example.com;MEMBER=&quot;urn:x-uid:group02&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:user08
</ins><span class="cx"> CREATED:20060101T150000Z
</span><del>-ORGANIZER;CN=User 01;EMAIL=user01@example.com:urn:x-uid:10000000-0000-0000-0000-000000000001
</del><ins>+ORGANIZER;CN=User 01;EMAIL=user01@example.com:urn:x-uid:user01
</ins><span class="cx"> SUMMARY:event 1
</span><span class="cx"> END:VEVENT
</span><span class="cx"> END:VCALENDAR
</span><span class="cx"> &quot;&quot;&quot;
</span><span class="cx"> 
</span><del>-        yield self._verifyObjectResourceCount(&quot;10000000-0000-0000-0000-000000000006&quot;, 0)
-        yield self._verifyObjectResourceCount(&quot;10000000-0000-0000-0000-000000000007&quot;, 0)
</del><ins>+        yield self._verifyObjectResourceCount(&quot;user06&quot;, 0)
+        yield self._verifyObjectResourceCount(&quot;user07&quot;, 0)
</ins><span class="cx"> 
</span><span class="cx">         vcalendar = Component.fromString(data_put_1)
</span><span class="cx">         yield calendar.createCalendarObjectWithName(&quot;data1.ics&quot;, vcalendar)
</span><span class="cx">         yield self.commit()
</span><span class="cx"> 
</span><del>-        cobj = yield self.calendarObjectUnderTest(name=&quot;data1.ics&quot;, calendar_name=&quot;calendar&quot;, home=&quot;10000000-0000-0000-0000-000000000001&quot;)
</del><ins>+        cobj = yield self.calendarObjectUnderTest(name=&quot;data1.ics&quot;, calendar_name=&quot;calendar&quot;, home=&quot;user01&quot;)
</ins><span class="cx">         vcalendar = yield cobj.component()
</span><span class="cx">         self._assertICalStrEqual(vcalendar, data_get_1)
</span><span class="cx"> 
</span><del>-        yield self._verifyObjectResourceCount(&quot;10000000-0000-0000-0000-000000000006&quot;, 1)
-        yield self._verifyObjectResourceCount(&quot;10000000-0000-0000-0000-000000000007&quot;, 1)
</del><ins>+        yield self._verifyObjectResourceCount(&quot;user06&quot;, 1)
+        yield self._verifyObjectResourceCount(&quot;user07&quot;, 1)
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><span class="lines">@@ -171,7 +173,7 @@
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         Test unknown group with CUTYPE=X-SERVER-GROUP handled
</span><span class="cx">         &quot;&quot;&quot;
</span><del>-        calendar = yield self.calendarUnderTest(name=&quot;calendar&quot;, home=&quot;10000000-0000-0000-0000-000000000001&quot;)
</del><ins>+        calendar = yield self.calendarUnderTest(name=&quot;calendar&quot;, home=&quot;user01&quot;)
</ins><span class="cx"> 
</span><span class="cx">         data_put_1 = &quot;&quot;&quot;BEGIN:VCALENDAR
</span><span class="cx"> CALSCALE:GREGORIAN
</span><span class="lines">@@ -198,10 +200,10 @@
</span><span class="cx"> UID:event1@ninevah.local
</span><span class="cx"> DTSTART:20140101T100000Z
</span><span class="cx"> DURATION:PT1H
</span><del>-ATTENDEE;CN=User 01;EMAIL=user01@example.com;RSVP=TRUE:urn:x-uid:10000000-0000-0000-0000-000000000001
</del><ins>+ATTENDEE;CN=User 01;EMAIL=user01@example.com;RSVP=TRUE:urn:x-uid:user01
</ins><span class="cx"> ATTENDEE;CUTYPE=X-SERVER-GROUP;RSVP=TRUE;SCHEDULE-STATUS=3.7:urn:uuid:FFFFFFFF-EEEE-DDDD-CCCC-BBBBBBBBBBBB
</span><span class="cx"> CREATED:20060101T150000Z
</span><del>-ORGANIZER;CN=User 01;EMAIL=user01@example.com:urn:x-uid:10000000-0000-0000-0000-000000000001
</del><ins>+ORGANIZER;CN=User 01;EMAIL=user01@example.com:urn:x-uid:user01
</ins><span class="cx"> SUMMARY:event 1
</span><span class="cx"> END:VEVENT
</span><span class="cx"> END:VCALENDAR
</span><span class="lines">@@ -211,7 +213,7 @@
</span><span class="cx">         yield calendar.createCalendarObjectWithName(&quot;data1.ics&quot;, vcalendar)
</span><span class="cx">         yield self.commit()
</span><span class="cx"> 
</span><del>-        cobj = yield self.calendarObjectUnderTest(name=&quot;data1.ics&quot;, calendar_name=&quot;calendar&quot;, home=&quot;10000000-0000-0000-0000-000000000001&quot;)
</del><ins>+        cobj = yield self.calendarObjectUnderTest(name=&quot;data1.ics&quot;, calendar_name=&quot;calendar&quot;, home=&quot;user01&quot;)
</ins><span class="cx">         vcalendar = yield cobj.component()
</span><span class="cx">         self.assertEqual(normalize_iCalStr(vcalendar), normalize_iCalStr(data_get_1))
</span><span class="cx"> 
</span><span class="lines">@@ -221,7 +223,7 @@
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         Test that primary attendee also in group remains primary
</span><span class="cx">         &quot;&quot;&quot;
</span><del>-        calendar = yield self.calendarUnderTest(name=&quot;calendar&quot;, home=&quot;10000000-0000-0000-0000-000000000001&quot;)
</del><ins>+        calendar = yield self.calendarUnderTest(name=&quot;calendar&quot;, home=&quot;user01&quot;)
</ins><span class="cx"> 
</span><span class="cx">         data_put_1 = &quot;&quot;&quot;BEGIN:VCALENDAR
</span><span class="cx"> CALSCALE:GREGORIAN
</span><span class="lines">@@ -249,11 +251,11 @@
</span><span class="cx"> UID:event1@ninevah.local
</span><span class="cx"> DTSTART:20140101T100000Z
</span><span class="cx"> DURATION:PT1H
</span><del>-ATTENDEE;CN=User 01;EMAIL=user01@example.com;RSVP=TRUE:urn:x-uid:10000000-0000-0000-0000-000000000001
-ATTENDEE;CN=User 02;EMAIL=user02@example.com;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:10000000-0000-0000-0000-000000000002
-ATTENDEE;CN=Group 01;CUTYPE=X-SERVER-GROUP;EMAIL=group01@example.com;RSVP=TRUE:urn:x-uid:20000000-0000-0000-0000-000000000001
</del><ins>+ATTENDEE;CN=User 01;EMAIL=user01@example.com;RSVP=TRUE:urn:x-uid:user01
+ATTENDEE;CN=User 02;EMAIL=user02@example.com;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:user02
+ATTENDEE;CN=Group 01;CUTYPE=X-SERVER-GROUP;EMAIL=group01@example.com;RSVP=TRUE:urn:x-uid:group01
</ins><span class="cx"> CREATED:20060101T150000Z
</span><del>-ORGANIZER;CN=User 01;EMAIL=user01@example.com:urn:x-uid:10000000-0000-0000-0000-000000000001
</del><ins>+ORGANIZER;CN=User 01;EMAIL=user01@example.com:urn:x-uid:user01
</ins><span class="cx"> SUMMARY:event 1
</span><span class="cx"> END:VEVENT
</span><span class="cx"> END:VCALENDAR
</span><span class="lines">@@ -262,7 +264,7 @@
</span><span class="cx">         yield calendar.createCalendarObjectWithName(&quot;data1.ics&quot;, vcalendar)
</span><span class="cx">         yield self.commit()
</span><span class="cx"> 
</span><del>-        cobj = yield self.calendarObjectUnderTest(name=&quot;data1.ics&quot;, calendar_name=&quot;calendar&quot;, home=&quot;10000000-0000-0000-0000-000000000001&quot;)
</del><ins>+        cobj = yield self.calendarObjectUnderTest(name=&quot;data1.ics&quot;, calendar_name=&quot;calendar&quot;, home=&quot;user01&quot;)
</ins><span class="cx">         vcalendar = yield cobj.component()
</span><span class="cx">         self.assertEqual(normalize_iCalStr(vcalendar), normalize_iCalStr(data_get_1))
</span><span class="cx"> 
</span><span class="lines">@@ -272,13 +274,13 @@
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         Test that nested groups are expanded expanded on PUT
</span><span class="cx">         &quot;&quot;&quot;
</span><del>-        yield self._verifyObjectResourceCount(&quot;10000000-0000-0000-0000-000000000006&quot;, 0)
-        yield self._verifyObjectResourceCount(&quot;10000000-0000-0000-0000-000000000007&quot;, 0)
-        yield self._verifyObjectResourceCount(&quot;10000000-0000-0000-0000-000000000008&quot;, 0)
-        yield self._verifyObjectResourceCount(&quot;10000000-0000-0000-0000-000000000009&quot;, 0)
-        yield self._verifyObjectResourceCount(&quot;10000000-0000-0000-0000-000000000010&quot;, 0)
</del><ins>+        yield self._verifyObjectResourceCount(&quot;user06&quot;, 0)
+        yield self._verifyObjectResourceCount(&quot;user07&quot;, 0)
+        yield self._verifyObjectResourceCount(&quot;user08&quot;, 0)
+        yield self._verifyObjectResourceCount(&quot;user09&quot;, 0)
+        yield self._verifyObjectResourceCount(&quot;user10&quot;, 0)
</ins><span class="cx"> 
</span><del>-        calendar = yield self.calendarUnderTest(name=&quot;calendar&quot;, home=&quot;10000000-0000-0000-0000-000000000001&quot;)
</del><ins>+        calendar = yield self.calendarUnderTest(name=&quot;calendar&quot;, home=&quot;user01&quot;)
</ins><span class="cx"> 
</span><span class="cx">         data_put_1 = &quot;&quot;&quot;BEGIN:VCALENDAR
</span><span class="cx"> CALSCALE:GREGORIAN
</span><span class="lines">@@ -293,7 +295,7 @@
</span><span class="cx"> UID:event1@ninevah.local
</span><span class="cx"> ORGANIZER:MAILTO:user01@example.com
</span><span class="cx"> ATTENDEE:mailto:user01@example.com
</span><del>-ATTENDEE:urn:x-uid:20000000-0000-0000-0000-000000000004
</del><ins>+ATTENDEE:urn:x-uid:group04
</ins><span class="cx"> END:VEVENT
</span><span class="cx"> END:VCALENDAR&quot;&quot;&quot;
</span><span class="cx"> 
</span><span class="lines">@@ -305,15 +307,15 @@
</span><span class="cx"> UID:event1@ninevah.local
</span><span class="cx"> DTSTART:20140101T100000Z
</span><span class="cx"> DURATION:PT1H
</span><del>-ATTENDEE;CN=User 01;EMAIL=user01@example.com;RSVP=TRUE:urn:x-uid:10000000-0000-0000-0000-000000000001
-ATTENDEE;CN=Group 04;CUTYPE=X-SERVER-GROUP;RSVP=TRUE:urn:x-uid:20000000-0000-0000-0000-000000000004
-ATTENDEE;CN=User 06;EMAIL=user06@example.com;MEMBER=&quot;urn:x-uid:20000000-0000-0000-0000-000000000004&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:10000000-0000-0000-0000-000000000006
-ATTENDEE;CN=User 07;EMAIL=user07@example.com;MEMBER=&quot;urn:x-uid:20000000-0000-0000-0000-000000000004&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:10000000-0000-0000-0000-000000000007
-ATTENDEE;CN=User 08;EMAIL=user08@example.com;MEMBER=&quot;urn:x-uid:20000000-0000-0000-0000-000000000004&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:10000000-0000-0000-0000-000000000008
-ATTENDEE;CN=User 09;EMAIL=user09@example.com;MEMBER=&quot;urn:x-uid:20000000-0000-0000-0000-000000000004&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:10000000-0000-0000-0000-000000000009
-ATTENDEE;CN=User 10;EMAIL=user10@example.com;MEMBER=&quot;urn:x-uid:20000000-0000-0000-0000-000000000004&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:10000000-0000-0000-0000-000000000010
</del><ins>+ATTENDEE;CN=User 01;EMAIL=user01@example.com;RSVP=TRUE:urn:x-uid:user01
+ATTENDEE;CN=Group 04;CUTYPE=X-SERVER-GROUP;RSVP=TRUE:urn:x-uid:group04
+ATTENDEE;CN=User 06;EMAIL=user06@example.com;MEMBER=&quot;urn:x-uid:group04&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:user06
+ATTENDEE;CN=User 07;EMAIL=user07@example.com;MEMBER=&quot;urn:x-uid:group04&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:user07
+ATTENDEE;CN=User 08;EMAIL=user08@example.com;MEMBER=&quot;urn:x-uid:group04&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:user08
+ATTENDEE;CN=User 09;EMAIL=user09@example.com;MEMBER=&quot;urn:x-uid:group04&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:user09
+ATTENDEE;CN=User 10;EMAIL=user10@example.com;MEMBER=&quot;urn:x-uid:group04&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:user10
</ins><span class="cx"> CREATED:20060101T150000Z
</span><del>-ORGANIZER;CN=User 01;EMAIL=user01@example.com:urn:x-uid:10000000-0000-0000-0000-000000000001
</del><ins>+ORGANIZER;CN=User 01;EMAIL=user01@example.com:urn:x-uid:user01
</ins><span class="cx"> SUMMARY:event 1
</span><span class="cx"> END:VEVENT
</span><span class="cx"> END:VCALENDAR
</span><span class="lines">@@ -323,15 +325,15 @@
</span><span class="cx">         yield calendar.createCalendarObjectWithName(&quot;data1.ics&quot;, vcalendar)
</span><span class="cx">         yield self.commit()
</span><span class="cx"> 
</span><del>-        cobj = yield self.calendarObjectUnderTest(name=&quot;data1.ics&quot;, calendar_name=&quot;calendar&quot;, home=&quot;10000000-0000-0000-0000-000000000001&quot;)
</del><ins>+        cobj = yield self.calendarObjectUnderTest(name=&quot;data1.ics&quot;, calendar_name=&quot;calendar&quot;, home=&quot;user01&quot;)
</ins><span class="cx">         vcalendar = yield cobj.component()
</span><span class="cx">         self._assertICalStrEqual(vcalendar, data_get_1)
</span><span class="cx"> 
</span><del>-        yield self._verifyObjectResourceCount(&quot;10000000-0000-0000-0000-000000000006&quot;, 1)
-        yield self._verifyObjectResourceCount(&quot;10000000-0000-0000-0000-000000000007&quot;, 1)
-        yield self._verifyObjectResourceCount(&quot;10000000-0000-0000-0000-000000000008&quot;, 1)
-        yield self._verifyObjectResourceCount(&quot;10000000-0000-0000-0000-000000000009&quot;, 1)
-        yield self._verifyObjectResourceCount(&quot;10000000-0000-0000-0000-000000000010&quot;, 1)
</del><ins>+        yield self._verifyObjectResourceCount(&quot;user06&quot;, 1)
+        yield self._verifyObjectResourceCount(&quot;user07&quot;, 1)
+        yield self._verifyObjectResourceCount(&quot;user08&quot;, 1)
+        yield self._verifyObjectResourceCount(&quot;user09&quot;, 1)
+        yield self._verifyObjectResourceCount(&quot;user10&quot;, 1)
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><span class="lines">@@ -339,12 +341,12 @@
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         Test that expanded users in two primary groups have groups in MEMBERS param
</span><span class="cx">         &quot;&quot;&quot;
</span><del>-        yield self._verifyObjectResourceCount(&quot;10000000-0000-0000-0000-000000000006&quot;, 0)
-        yield self._verifyObjectResourceCount(&quot;10000000-0000-0000-0000-000000000007&quot;, 0)
-        yield self._verifyObjectResourceCount(&quot;10000000-0000-0000-0000-000000000008&quot;, 0)
-        yield self._verifyObjectResourceCount(&quot;10000000-0000-0000-0000-000000000009&quot;, 0)
</del><ins>+        yield self._verifyObjectResourceCount(&quot;user06&quot;, 0)
+        yield self._verifyObjectResourceCount(&quot;user07&quot;, 0)
+        yield self._verifyObjectResourceCount(&quot;user08&quot;, 0)
+        yield self._verifyObjectResourceCount(&quot;user09&quot;, 0)
</ins><span class="cx"> 
</span><del>-        calendar = yield self.calendarUnderTest(name=&quot;calendar&quot;, home=&quot;10000000-0000-0000-0000-000000000001&quot;)
</del><ins>+        calendar = yield self.calendarUnderTest(name=&quot;calendar&quot;, home=&quot;user01&quot;)
</ins><span class="cx"> 
</span><span class="cx">         data_put_1 = &quot;&quot;&quot;BEGIN:VCALENDAR
</span><span class="cx"> CALSCALE:GREGORIAN
</span><span class="lines">@@ -373,16 +375,16 @@
</span><span class="cx"> UID:event1@ninevah.local
</span><span class="cx"> DTSTART:20140101T100000Z
</span><span class="cx"> DURATION:PT1H
</span><del>-ATTENDEE;CN=User 01;EMAIL=user01@example.com;RSVP=TRUE:urn:x-uid:10000000-0000-0000-0000-000000000001
-ATTENDEE;CN=Group 01;CUTYPE=X-SERVER-GROUP;EMAIL=group01@example.com;RSVP=TRUE:urn:x-uid:20000000-0000-0000-0000-000000000001
-ATTENDEE;CN=Group 02;CUTYPE=X-SERVER-GROUP;EMAIL=group02@example.com;RSVP=TRUE:urn:x-uid:20000000-0000-0000-0000-000000000002
-ATTENDEE;CN=Group 03;CUTYPE=X-SERVER-GROUP;EMAIL=group03@example.com;RSVP=TRUE:urn:x-uid:20000000-0000-0000-0000-000000000003
-ATTENDEE;CN=User 06;EMAIL=user06@example.com;MEMBER=&quot;urn:x-uid:20000000-0000-0000-0000-000000000002&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:10000000-0000-0000-0000-000000000006
-ATTENDEE;CN=User 07;EMAIL=user07@example.com;MEMBER=&quot;urn:x-uid:20000000-0000-0000-0000-000000000002&quot;,&quot;urn:x-uid:20000000-0000-0000-0000-000000000003&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:10000000-0000-0000-0000-000000000007
-ATTENDEE;CN=User 08;EMAIL=user08@example.com;MEMBER=&quot;urn:x-uid:20000000-0000-0000-0000-000000000002&quot;,&quot;urn:x-uid:20000000-0000-0000-0000-000000000003&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:10000000-0000-0000-0000-000000000008
-ATTENDEE;CN=User 09;EMAIL=user09@example.com;MEMBER=&quot;urn:x-uid:20000000-0000-0000-0000-000000000003&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:10000000-0000-0000-0000-000000000009
</del><ins>+ATTENDEE;CN=User 01;EMAIL=user01@example.com;RSVP=TRUE:urn:x-uid:user01
+ATTENDEE;CN=Group 01;CUTYPE=X-SERVER-GROUP;EMAIL=group01@example.com;RSVP=TRUE:urn:x-uid:group01
+ATTENDEE;CN=Group 02;CUTYPE=X-SERVER-GROUP;EMAIL=group02@example.com;RSVP=TRUE:urn:x-uid:group02
+ATTENDEE;CN=Group 03;CUTYPE=X-SERVER-GROUP;EMAIL=group03@example.com;RSVP=TRUE:urn:x-uid:group03
+ATTENDEE;CN=User 06;EMAIL=user06@example.com;MEMBER=&quot;urn:x-uid:group02&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:user06
+ATTENDEE;CN=User 07;EMAIL=user07@example.com;MEMBER=&quot;urn:x-uid:group02&quot;,&quot;urn:x-uid:group03&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:user07
+ATTENDEE;CN=User 08;EMAIL=user08@example.com;MEMBER=&quot;urn:x-uid:group02&quot;,&quot;urn:x-uid:group03&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:user08
+ATTENDEE;CN=User 09;EMAIL=user09@example.com;MEMBER=&quot;urn:x-uid:group03&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:user09
</ins><span class="cx"> CREATED:20060101T150000Z
</span><del>-ORGANIZER;CN=User 01;EMAIL=user01@example.com:urn:x-uid:10000000-0000-0000-0000-000000000001
</del><ins>+ORGANIZER;CN=User 01;EMAIL=user01@example.com:urn:x-uid:user01
</ins><span class="cx"> SUMMARY:event 1
</span><span class="cx"> END:VEVENT
</span><span class="cx"> END:VCALENDAR&quot;&quot;&quot;
</span><span class="lines">@@ -391,17 +393,81 @@
</span><span class="cx">         yield calendar.createCalendarObjectWithName(&quot;data1.ics&quot;, vcalendar)
</span><span class="cx">         yield self.commit()
</span><span class="cx"> 
</span><del>-        cobj = yield self.calendarObjectUnderTest(name=&quot;data1.ics&quot;, calendar_name=&quot;calendar&quot;, home=&quot;10000000-0000-0000-0000-000000000001&quot;)
</del><ins>+        cobj = yield self.calendarObjectUnderTest(name=&quot;data1.ics&quot;, calendar_name=&quot;calendar&quot;, home=&quot;user01&quot;)
</ins><span class="cx">         vcalendar = yield cobj.component()
</span><span class="cx">         self._assertICalStrEqual(vcalendar, data_get_1)
</span><span class="cx"> 
</span><del>-        yield self._verifyObjectResourceCount(&quot;10000000-0000-0000-0000-000000000006&quot;, 1)
-        yield self._verifyObjectResourceCount(&quot;10000000-0000-0000-0000-000000000007&quot;, 1)
-        yield self._verifyObjectResourceCount(&quot;10000000-0000-0000-0000-000000000008&quot;, 1)
-        yield self._verifyObjectResourceCount(&quot;10000000-0000-0000-0000-000000000009&quot;, 1)
</del><ins>+        yield self._verifyObjectResourceCount(&quot;user06&quot;, 1)
+        yield self._verifyObjectResourceCount(&quot;user07&quot;, 1)
+        yield self._verifyObjectResourceCount(&quot;user08&quot;, 1)
+        yield self._verifyObjectResourceCount(&quot;user09&quot;, 1)
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><ins>+    def test_groupPutOldEvent(self):
+        &quot;&quot;&quot;
+        Test that old event with group attendee is expaned but not linked to group update
+        &quot;&quot;&quot;
+
+        data_put_1 = &quot;&quot;&quot;BEGIN:VCALENDAR
+CALSCALE:GREGORIAN
+PRODID:-//Example Inc.//Example Calendar//EN
+VERSION:2.0
+BEGIN:VEVENT
+DTSTAMP:20051222T205953Z
+CREATED:20060101T150000Z
+DTSTART:20140101T100000Z
+DURATION:PT1H
+SUMMARY:event 1
+UID:event1@ninevah.local
+ORGANIZER:MAILTO:user02@example.com
+ATTENDEE:mailto:user02@example.com
+ATTENDEE:MAILTO:group01@example.com
+END:VEVENT
+END:VCALENDAR&quot;&quot;&quot;
+
+        data_get_1 = &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+CALSCALE:GREGORIAN
+PRODID:-//Example Inc.//Example Calendar//EN
+BEGIN:VEVENT
+UID:event1@ninevah.local
+DTSTART:20140101T100000Z
+DURATION:PT1H
+ATTENDEE;CN=User 02;EMAIL=user02@example.com;RSVP=TRUE:urn:x-uid:user02
+ATTENDEE;CN=Group 01;CUTYPE=X-SERVER-GROUP;EMAIL=group01@example.com;RSVP=TRUE:urn:x-uid:group01
+ATTENDEE;CN=User 01;EMAIL=user01@example.com;MEMBER=&quot;urn:x-uid:group01&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:user01
+CREATED:20060101T150000Z
+ORGANIZER;CN=User 02;EMAIL=user02@example.com:urn:x-uid:user02
+SUMMARY:event 1
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot;
+        groupCacher = GroupCacher(self.transactionUnderTest().directoryService())
+
+        calendar = yield self.calendarUnderTest(name=&quot;calendar&quot;, home=&quot;user02&quot;)
+        vcalendar = Component.fromString(data_put_1)
+        yield calendar.createCalendarObjectWithName(&quot;data1.ics&quot;, vcalendar)
+        yield self.commit()
+
+        groupsToRefresh = yield groupCacher.groupsToRefresh(self.transactionUnderTest())
+        self.assertEqual(len(groupsToRefresh), 0)
+
+        wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), &quot;group01&quot;)
+        if len(wps): # This is needed because the test currently fails and does actually create job items we have to wait for
+            yield self.commit()
+            yield JobItem.waitEmpty(self._sqlCalendarStore.newTransaction, reactor, 60)
+        self.assertEqual(len(wps), 0)
+
+        cobj = yield self.calendarObjectUnderTest(name=&quot;data1.ics&quot;, calendar_name=&quot;calendar&quot;, home=&quot;user02&quot;)
+        vcalendar = yield cobj.component()
+        self.assertEqual(normalize_iCalStr(vcalendar), normalize_iCalStr(data_get_1))
+
+
+
+class GroupAttendeeReconciliationTests(GroupAttendeeTestBase):
+
+    @inlineCallbacks
</ins><span class="cx">     def test_groupChange(self):
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         Test that group attendee are changed when the group changes.
</span><span class="lines">@@ -432,10 +498,10 @@
</span><span class="cx"> UID:event1@ninevah.local
</span><span class="cx"> DTSTART:20240101T100000Z
</span><span class="cx"> DURATION:PT1H
</span><del>-ATTENDEE;CN=User 02;EMAIL=user02@example.com;RSVP=TRUE:urn:x-uid:10000000-0000-0000-0000-000000000002
-ATTENDEE;CN=Group 01;CUTYPE=X-SERVER-GROUP;EMAIL=group01@example.com;RSVP=TRUE:urn:x-uid:20000000-0000-0000-0000-000000000001
</del><ins>+ATTENDEE;CN=User 02;EMAIL=user02@example.com;RSVP=TRUE:urn:x-uid:user02
+ATTENDEE;CN=Group 01;CUTYPE=X-SERVER-GROUP;EMAIL=group01@example.com;RSVP=TRUE:urn:x-uid:group01
</ins><span class="cx"> CREATED:20060101T150000Z
</span><del>-ORGANIZER;CN=User 02;EMAIL=user02@example.com:urn:x-uid:10000000-0000-0000-0000-000000000002
</del><ins>+ORGANIZER;CN=User 02;EMAIL=user02@example.com:urn:x-uid:user02
</ins><span class="cx"> SUMMARY:event 1
</span><span class="cx"> END:VEVENT
</span><span class="cx"> END:VCALENDAR
</span><span class="lines">@@ -449,11 +515,11 @@
</span><span class="cx"> UID:event1@ninevah.local
</span><span class="cx"> DTSTART:20240101T100000Z
</span><span class="cx"> DURATION:PT1H
</span><del>-ATTENDEE;CN=User 02;EMAIL=user02@example.com;RSVP=TRUE:urn:x-uid:10000000-0000-0000-0000-000000000002
-ATTENDEE;CN=Group 01;CUTYPE=X-SERVER-GROUP;EMAIL=group01@example.com;RSVP=TRUE:urn:x-uid:20000000-0000-0000-0000-000000000001
-ATTENDEE;CN=User 01;EMAIL=user01@example.com;MEMBER=&quot;urn:x-uid:20000000-0000-0000-0000-000000000001&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:10000000-0000-0000-0000-000000000001
</del><ins>+ATTENDEE;CN=User 02;EMAIL=user02@example.com;RSVP=TRUE:urn:x-uid:user02
+ATTENDEE;CN=Group 01;CUTYPE=X-SERVER-GROUP;EMAIL=group01@example.com;RSVP=TRUE:urn:x-uid:group01
+ATTENDEE;CN=User 01;EMAIL=user01@example.com;MEMBER=&quot;urn:x-uid:group01&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:user01
</ins><span class="cx"> CREATED:20060101T150000Z
</span><del>-ORGANIZER;CN=User 02;EMAIL=user02@example.com:urn:x-uid:10000000-0000-0000-0000-000000000002
</del><ins>+ORGANIZER;CN=User 02;EMAIL=user02@example.com:urn:x-uid:user02
</ins><span class="cx"> SEQUENCE:1
</span><span class="cx"> SUMMARY:event 1
</span><span class="cx"> END:VEVENT
</span><span class="lines">@@ -468,10 +534,10 @@
</span><span class="cx"> UID:event1@ninevah.local
</span><span class="cx"> DTSTART:20240101T100000Z
</span><span class="cx"> DURATION:PT1H
</span><del>-ATTENDEE;CN=User 02;EMAIL=user02@example.com;RSVP=TRUE:urn:x-uid:10000000-0000-0000-0000-000000000002
-ATTENDEE;CN=Group 01;CUTYPE=X-SERVER-GROUP;EMAIL=group01@example.com;RSVP=TRUE:urn:x-uid:20000000-0000-0000-0000-000000000001
</del><ins>+ATTENDEE;CN=User 02;EMAIL=user02@example.com;RSVP=TRUE:urn:x-uid:user02
+ATTENDEE;CN=Group 01;CUTYPE=X-SERVER-GROUP;EMAIL=group01@example.com;RSVP=TRUE:urn:x-uid:group01
</ins><span class="cx"> CREATED:20060101T150000Z
</span><del>-ORGANIZER;CN=User 02;EMAIL=user02@example.com:urn:x-uid:10000000-0000-0000-0000-000000000002
</del><ins>+ORGANIZER;CN=User 02;EMAIL=user02@example.com:urn:x-uid:user02
</ins><span class="cx"> SEQUENCE:2
</span><span class="cx"> SUMMARY:event 1
</span><span class="cx"> END:VEVENT
</span><span class="lines">@@ -490,50 +556,50 @@
</span><span class="cx">         groupsToRefresh = yield groupCacher.groupsToRefresh(self.transactionUnderTest())
</span><span class="cx">         self.assertEqual(len(groupsToRefresh), 0)
</span><span class="cx"> 
</span><del>-        wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), &quot;20000000-0000-0000-0000-000000000001&quot;)
</del><ins>+        wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), &quot;group01&quot;)
</ins><span class="cx">         self.assertEqual(len(wps), 0)
</span><span class="cx"> 
</span><del>-        calendar = yield self.calendarUnderTest(name=&quot;calendar&quot;, home=&quot;10000000-0000-0000-0000-000000000002&quot;)
</del><ins>+        calendar = yield self.calendarUnderTest(name=&quot;calendar&quot;, home=&quot;user02&quot;)
</ins><span class="cx">         vcalendar = Component.fromString(data_put_1)
</span><span class="cx">         yield calendar.createCalendarObjectWithName(&quot;data1.ics&quot;, vcalendar)
</span><span class="cx">         yield self.commit()
</span><span class="cx"> 
</span><del>-        cobj = yield self.calendarObjectUnderTest(name=&quot;data1.ics&quot;, calendar_name=&quot;calendar&quot;, home=&quot;10000000-0000-0000-0000-000000000002&quot;)
</del><ins>+        cobj = yield self.calendarObjectUnderTest(name=&quot;data1.ics&quot;, calendar_name=&quot;calendar&quot;, home=&quot;user02&quot;)
</ins><span class="cx">         vcalendar = yield cobj.component()
</span><span class="cx">         self.assertEqual(normalize_iCalStr(vcalendar), normalize_iCalStr(data_get_2))
</span><span class="cx"> 
</span><del>-        yield self._verifyObjectResourceCount(&quot;10000000-0000-0000-0000-000000000001&quot;, 0)
</del><ins>+        yield self._verifyObjectResourceCount(&quot;user01&quot;, 0)
</ins><span class="cx">         yield self.commit()
</span><span class="cx"> 
</span><span class="cx">         self.patch(CalendarDirectoryRecordMixin, &quot;expandedMembers&quot;, unpatchedExpandedMembers)
</span><span class="cx"> 
</span><span class="cx">         groupsToRefresh = yield groupCacher.groupsToRefresh(self.transactionUnderTest())
</span><span class="cx">         self.assertEqual(len(groupsToRefresh), 1)
</span><del>-        self.assertEqual(list(groupsToRefresh)[0], &quot;20000000-0000-0000-0000-000000000001&quot;)
</del><ins>+        self.assertEqual(list(groupsToRefresh)[0], &quot;group01&quot;)
</ins><span class="cx"> 
</span><del>-        wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), &quot;20000000-0000-0000-0000-000000000001&quot;)
</del><ins>+        wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), &quot;group01&quot;)
</ins><span class="cx">         yield self.commit()
</span><span class="cx">         self.assertEqual(len(wps), 1)
</span><span class="cx">         yield JobItem.waitEmpty(self._sqlCalendarStore.newTransaction, reactor, 60)
</span><span class="cx"> 
</span><del>-        cobj = yield self.calendarObjectUnderTest(name=&quot;data1.ics&quot;, calendar_name=&quot;calendar&quot;, home=&quot;10000000-0000-0000-0000-000000000002&quot;)
</del><ins>+        cobj = yield self.calendarObjectUnderTest(name=&quot;data1.ics&quot;, calendar_name=&quot;calendar&quot;, home=&quot;user02&quot;)
</ins><span class="cx">         vcalendar = yield cobj.component()
</span><span class="cx">         self.assertEqual(normalize_iCalStr(vcalendar), normalize_iCalStr(data_get_3))
</span><span class="cx"> 
</span><del>-        yield self._verifyObjectResourceCount(&quot;10000000-0000-0000-0000-000000000001&quot;, 1)
</del><ins>+        yield self._verifyObjectResourceCount(&quot;user01&quot;, 1)
</ins><span class="cx">         yield self.commit()
</span><span class="cx"> 
</span><span class="cx">         self.patch(CalendarDirectoryRecordMixin, &quot;expandedMembers&quot;, expandedMembers)
</span><del>-        wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), &quot;20000000-0000-0000-0000-000000000001&quot;)
</del><ins>+        wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), &quot;group01&quot;)
</ins><span class="cx">         yield self.commit()
</span><span class="cx">         self.assertEqual(len(wps), 1)
</span><span class="cx">         yield JobItem.waitEmpty(self._sqlCalendarStore.newTransaction, reactor, 60)
</span><span class="cx"> 
</span><del>-        cobj = yield self.calendarObjectUnderTest(name=&quot;data1.ics&quot;, calendar_name=&quot;calendar&quot;, home=&quot;10000000-0000-0000-0000-000000000002&quot;)
</del><ins>+        cobj = yield self.calendarObjectUnderTest(name=&quot;data1.ics&quot;, calendar_name=&quot;calendar&quot;, home=&quot;user02&quot;)
</ins><span class="cx">         vcalendar = yield cobj.component()
</span><span class="cx">         self.assertEqual(normalize_iCalStr(vcalendar), normalize_iCalStr(data_get_4))
</span><span class="cx"> 
</span><del>-        cal = yield self.calendarUnderTest(name=&quot;calendar&quot;, home=&quot;10000000-0000-0000-0000-000000000001&quot;)
</del><ins>+        cal = yield self.calendarUnderTest(name=&quot;calendar&quot;, home=&quot;user01&quot;)
</ins><span class="cx">         cobjs = yield cal.objectResources()
</span><span class="cx">         self.assertEqual(len(cobjs), 1)
</span><span class="cx">         comp = yield cobjs[0].componentForUser()
</span><span class="lines">@@ -571,10 +637,10 @@
</span><span class="cx"> UID:event{0}@ninevah.local
</span><span class="cx"> DTSTART:20240101T100000Z
</span><span class="cx"> DURATION:PT1H
</span><del>-ATTENDEE;CN=User 0{0};EMAIL=user0{0}@example.com;RSVP=TRUE:urn:x-uid:10000000-0000-0000-0000-00000000000{0}
-ATTENDEE;CN=Group 01;CUTYPE=X-SERVER-GROUP;EMAIL=group01@example.com;RSVP=TRUE:urn:x-uid:20000000-0000-0000-0000-000000000001
</del><ins>+ATTENDEE;CN=User 0{0};EMAIL=user0{0}@example.com;RSVP=TRUE:urn:x-uid:user0{0}
+ATTENDEE;CN=Group 01;CUTYPE=X-SERVER-GROUP;EMAIL=group01@example.com;RSVP=TRUE:urn:x-uid:group01
</ins><span class="cx"> CREATED:20060101T150000Z
</span><del>-ORGANIZER;CN=User 0{0};EMAIL=user0{0}@example.com:urn:x-uid:10000000-0000-0000-0000-00000000000{0}
</del><ins>+ORGANIZER;CN=User 0{0};EMAIL=user0{0}@example.com:urn:x-uid:user0{0}
</ins><span class="cx"> SUMMARY:event {0}
</span><span class="cx"> END:VEVENT
</span><span class="cx"> END:VCALENDAR
</span><span class="lines">@@ -588,11 +654,11 @@
</span><span class="cx"> UID:event{0}@ninevah.local
</span><span class="cx"> DTSTART:20240101T100000Z
</span><span class="cx"> DURATION:PT1H
</span><del>-ATTENDEE;CN=User 0{0};EMAIL=user0{0}@example.com;RSVP=TRUE:urn:x-uid:10000000-0000-0000-0000-00000000000{0}
-ATTENDEE;CN=Group 01;CUTYPE=X-SERVER-GROUP;EMAIL=group01@example.com;RSVP=TRUE:urn:x-uid:20000000-0000-0000-0000-000000000001
-ATTENDEE;CN=User 01;EMAIL=user01@example.com;MEMBER=&quot;urn:x-uid:20000000-0000-0000-0000-000000000001&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:10000000-0000-0000-0000-000000000001
</del><ins>+ATTENDEE;CN=User 0{0};EMAIL=user0{0}@example.com;RSVP=TRUE:urn:x-uid:user0{0}
+ATTENDEE;CN=Group 01;CUTYPE=X-SERVER-GROUP;EMAIL=group01@example.com;RSVP=TRUE:urn:x-uid:group01
+ATTENDEE;CN=User 01;EMAIL=user01@example.com;MEMBER=&quot;urn:x-uid:group01&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:user01
</ins><span class="cx"> CREATED:20060101T150000Z
</span><del>-ORGANIZER;CN=User 0{0};EMAIL=user0{0}@example.com:urn:x-uid:10000000-0000-0000-0000-00000000000{0}
</del><ins>+ORGANIZER;CN=User 0{0};EMAIL=user0{0}@example.com:urn:x-uid:user0{0}
</ins><span class="cx"> SEQUENCE:1
</span><span class="cx"> SUMMARY:event {0}
</span><span class="cx"> END:VEVENT
</span><span class="lines">@@ -607,10 +673,10 @@
</span><span class="cx"> UID:event{0}@ninevah.local
</span><span class="cx"> DTSTART:20240101T100000Z
</span><span class="cx"> DURATION:PT1H
</span><del>-ATTENDEE;CN=User 0{0};EMAIL=user0{0}@example.com;RSVP=TRUE:urn:x-uid:10000000-0000-0000-0000-00000000000{0}
-ATTENDEE;CN=Group 01;CUTYPE=X-SERVER-GROUP;EMAIL=group01@example.com;RSVP=TRUE:urn:x-uid:20000000-0000-0000-0000-000000000001
</del><ins>+ATTENDEE;CN=User 0{0};EMAIL=user0{0}@example.com;RSVP=TRUE:urn:x-uid:user0{0}
+ATTENDEE;CN=Group 01;CUTYPE=X-SERVER-GROUP;EMAIL=group01@example.com;RSVP=TRUE:urn:x-uid:group01
</ins><span class="cx"> CREATED:20060101T150000Z
</span><del>-ORGANIZER;CN=User 0{0};EMAIL=user0{0}@example.com:urn:x-uid:10000000-0000-0000-0000-00000000000{0}
</del><ins>+ORGANIZER;CN=User 0{0};EMAIL=user0{0}@example.com:urn:x-uid:user0{0}
</ins><span class="cx"> SEQUENCE:2
</span><span class="cx"> SUMMARY:event {0}
</span><span class="cx"> END:VEVENT
</span><span class="lines">@@ -629,55 +695,55 @@
</span><span class="cx">         groupsToRefresh = yield groupCacher.groupsToRefresh(self.transactionUnderTest())
</span><span class="cx">         self.assertEqual(len(groupsToRefresh), 0)
</span><span class="cx"> 
</span><del>-        wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), &quot;20000000-0000-0000-0000-000000000001&quot;)
</del><ins>+        wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), &quot;group01&quot;)
</ins><span class="cx">         self.assertEqual(len(wps), 0)
</span><span class="cx"> 
</span><span class="cx">         userRange = range(6, 10) # have to be 1 diget and homes in requirements
</span><span class="cx"> 
</span><span class="cx">         for i in userRange:
</span><del>-            calendar = yield self.calendarUnderTest(name=&quot;calendar&quot;, home=&quot;10000000-0000-0000-0000-00000000000{0}&quot;.format(i))
</del><ins>+            calendar = yield self.calendarUnderTest(name=&quot;calendar&quot;, home=&quot;user0{0}&quot;.format(i))
</ins><span class="cx">             vcalendar = Component.fromString(data_put_1.format(i))
</span><span class="cx">             yield calendar.createCalendarObjectWithName(&quot;data1.ics&quot;, vcalendar)
</span><span class="cx">             yield self.commit()
</span><span class="cx"> 
</span><del>-            cobj = yield self.calendarObjectUnderTest(name=&quot;data1.ics&quot;, calendar_name=&quot;calendar&quot;, home=&quot;10000000-0000-0000-0000-00000000000{0}&quot;.format(i))
</del><ins>+            cobj = yield self.calendarObjectUnderTest(name=&quot;data1.ics&quot;, calendar_name=&quot;calendar&quot;, home=&quot;user0{0}&quot;.format(i))
</ins><span class="cx">             vcalendar = yield cobj.component()
</span><span class="cx">             self.assertEqual(normalize_iCalStr(vcalendar), normalize_iCalStr(data_get_2.format(i)))
</span><span class="cx"> 
</span><del>-        yield self._verifyObjectResourceCount(&quot;10000000-0000-0000-0000-000000000001&quot;, 0)
</del><ins>+        yield self._verifyObjectResourceCount(&quot;user01&quot;, 0)
</ins><span class="cx">         yield self.commit()
</span><span class="cx"> 
</span><span class="cx">         self.patch(CalendarDirectoryRecordMixin, &quot;expandedMembers&quot;, unpatchedExpandedMembers)
</span><span class="cx"> 
</span><span class="cx">         groupsToRefresh = yield groupCacher.groupsToRefresh(self.transactionUnderTest())
</span><span class="cx">         self.assertEqual(len(groupsToRefresh), 1)
</span><del>-        self.assertEqual(list(groupsToRefresh)[0], &quot;20000000-0000-0000-0000-000000000001&quot;)
</del><ins>+        self.assertEqual(list(groupsToRefresh)[0], &quot;group01&quot;)
</ins><span class="cx"> 
</span><del>-        wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), &quot;20000000-0000-0000-0000-000000000001&quot;)
</del><ins>+        wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), &quot;group01&quot;)
</ins><span class="cx">         yield self.commit()
</span><span class="cx">         self.assertEqual(len(wps), len(userRange))
</span><span class="cx">         yield JobItem.waitEmpty(self._sqlCalendarStore.newTransaction, reactor, 60)
</span><span class="cx"> 
</span><span class="cx">         for i in userRange:
</span><del>-            cobj = yield self.calendarObjectUnderTest(name=&quot;data1.ics&quot;, calendar_name=&quot;calendar&quot;, home=&quot;10000000-0000-0000-0000-00000000000{0}&quot;.format(i))
</del><ins>+            cobj = yield self.calendarObjectUnderTest(name=&quot;data1.ics&quot;, calendar_name=&quot;calendar&quot;, home=&quot;user0{0}&quot;.format(i))
</ins><span class="cx">             vcalendar = yield cobj.component()
</span><span class="cx">             self.assertEqual(normalize_iCalStr(vcalendar), normalize_iCalStr(data_get_3.format(i)))
</span><span class="cx"> 
</span><del>-        yield self._verifyObjectResourceCount(&quot;10000000-0000-0000-0000-000000000001&quot;, len(userRange))
</del><ins>+        yield self._verifyObjectResourceCount(&quot;user01&quot;, len(userRange))
</ins><span class="cx">         yield self.commit()
</span><span class="cx"> 
</span><span class="cx">         self.patch(CalendarDirectoryRecordMixin, &quot;expandedMembers&quot;, expandedMembers)
</span><del>-        wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), &quot;20000000-0000-0000-0000-000000000001&quot;)
</del><ins>+        wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), &quot;group01&quot;)
</ins><span class="cx">         yield self.commit()
</span><span class="cx">         self.assertEqual(len(wps), len(userRange))
</span><span class="cx">         yield JobItem.waitEmpty(self._sqlCalendarStore.newTransaction, reactor, 60)
</span><span class="cx"> 
</span><span class="cx">         for i in userRange:
</span><del>-            cobj = yield self.calendarObjectUnderTest(name=&quot;data1.ics&quot;, calendar_name=&quot;calendar&quot;, home=&quot;10000000-0000-0000-0000-00000000000{0}&quot;.format(i))
</del><ins>+            cobj = yield self.calendarObjectUnderTest(name=&quot;data1.ics&quot;, calendar_name=&quot;calendar&quot;, home=&quot;user0{0}&quot;.format(i))
</ins><span class="cx">             vcalendar = yield cobj.component()
</span><span class="cx">             self.assertEqual(normalize_iCalStr(vcalendar), normalize_iCalStr(data_get_4.format(i)))
</span><span class="cx"> 
</span><del>-        cal = yield self.calendarUnderTest(name=&quot;calendar&quot;, home=&quot;10000000-0000-0000-0000-000000000001&quot;)
</del><ins>+        cal = yield self.calendarUnderTest(name=&quot;calendar&quot;, home=&quot;user01&quot;)
</ins><span class="cx">         cobjs = yield cal.objectResources()
</span><span class="cx">         self.assertEqual(len(cobjs), len(userRange))
</span><span class="cx">         for cobj in cobjs:
</span><span class="lines">@@ -686,67 +752,6 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><del>-    def test_groupPutOldEvent(self):
-        &quot;&quot;&quot;
-        Test that old event with group attendee is expaned but not linked to group update
-        &quot;&quot;&quot;
-
-        data_put_1 = &quot;&quot;&quot;BEGIN:VCALENDAR
-CALSCALE:GREGORIAN
-PRODID:-//Example Inc.//Example Calendar//EN
-VERSION:2.0
-BEGIN:VEVENT
-DTSTAMP:20051222T205953Z
-CREATED:20060101T150000Z
-DTSTART:20140101T100000Z
-DURATION:PT1H
-SUMMARY:event 1
-UID:event1@ninevah.local
-ORGANIZER:MAILTO:user02@example.com
-ATTENDEE:mailto:user02@example.com
-ATTENDEE:MAILTO:group01@example.com
-END:VEVENT
-END:VCALENDAR&quot;&quot;&quot;
-
-        data_get_1 = &quot;&quot;&quot;BEGIN:VCALENDAR
-VERSION:2.0
-CALSCALE:GREGORIAN
-PRODID:-//Example Inc.//Example Calendar//EN
-BEGIN:VEVENT
-UID:event1@ninevah.local
-DTSTART:20140101T100000Z
-DURATION:PT1H
-ATTENDEE;CN=User 02;EMAIL=user02@example.com;RSVP=TRUE:urn:x-uid:10000000-0000-0000-0000-000000000002
-ATTENDEE;CN=Group 01;CUTYPE=X-SERVER-GROUP;EMAIL=group01@example.com;RSVP=TRUE:urn:x-uid:20000000-0000-0000-0000-000000000001
-ATTENDEE;CN=User 01;EMAIL=user01@example.com;MEMBER=&quot;urn:x-uid:20000000-0000-0000-0000-000000000001&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:10000000-0000-0000-0000-000000000001
-CREATED:20060101T150000Z
-ORGANIZER;CN=User 02;EMAIL=user02@example.com:urn:x-uid:10000000-0000-0000-0000-000000000002
-SUMMARY:event 1
-END:VEVENT
-END:VCALENDAR
-&quot;&quot;&quot;
-        groupCacher = GroupCacher(self.transactionUnderTest().directoryService())
-
-        calendar = yield self.calendarUnderTest(name=&quot;calendar&quot;, home=&quot;10000000-0000-0000-0000-000000000002&quot;)
-        vcalendar = Component.fromString(data_put_1)
-        yield calendar.createCalendarObjectWithName(&quot;data1.ics&quot;, vcalendar)
-        yield self.commit()
-
-        groupsToRefresh = yield groupCacher.groupsToRefresh(self.transactionUnderTest())
-        self.assertEqual(len(groupsToRefresh), 0)
-
-        wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), &quot;20000000-0000-0000-0000-000000000001&quot;)
-        if len(wps): # This is needed because the test currently fails and does actually create job items we have to wait for
-            yield self.commit()
-            yield JobItem.waitEmpty(self._sqlCalendarStore.newTransaction, reactor, 60)
-        self.assertEqual(len(wps), 0)
-
-        cobj = yield self.calendarObjectUnderTest(name=&quot;data1.ics&quot;, calendar_name=&quot;calendar&quot;, home=&quot;10000000-0000-0000-0000-000000000002&quot;)
-        vcalendar = yield cobj.component()
-        self.assertEqual(normalize_iCalStr(vcalendar), normalize_iCalStr(data_get_1))
-
-
-    @inlineCallbacks
</del><span class="cx">     def test_groupChangeOldEvent(self):
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         Test that group attendee changes not applied to old events
</span><span class="lines">@@ -794,11 +799,11 @@
</span><span class="cx"> UID:event1@ninevah.local
</span><span class="cx"> DTSTART:20240101T100000Z
</span><span class="cx"> DURATION:PT1H
</span><del>-ATTENDEE;CN=User 02;EMAIL=user02@example.com;RSVP=TRUE:urn:x-uid:10000000-0000-0000-0000-000000000002
-ATTENDEE;CN=Group 01;CUTYPE=X-SERVER-GROUP;EMAIL=group01@example.com;RSVP=TRUE:urn:x-uid:20000000-0000-0000-0000-000000000001
-ATTENDEE;CN=User 01;EMAIL=user01@example.com;MEMBER=&quot;urn:x-uid:20000000-0000-0000-0000-000000000001&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:10000000-0000-0000-0000-000000000001
</del><ins>+ATTENDEE;CN=User 02;EMAIL=user02@example.com;RSVP=TRUE:urn:x-uid:user02
+ATTENDEE;CN=Group 01;CUTYPE=X-SERVER-GROUP;EMAIL=group01@example.com;RSVP=TRUE:urn:x-uid:group01
+ATTENDEE;CN=User 01;EMAIL=user01@example.com;MEMBER=&quot;urn:x-uid:group01&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:user01
</ins><span class="cx"> CREATED:20060101T150000Z
</span><del>-ORGANIZER;CN=User 02;EMAIL=user02@example.com:urn:x-uid:10000000-0000-0000-0000-000000000002
</del><ins>+ORGANIZER;CN=User 02;EMAIL=user02@example.com:urn:x-uid:user02
</ins><span class="cx"> SUMMARY:event 1
</span><span class="cx"> END:VEVENT
</span><span class="cx"> END:VCALENDAR
</span><span class="lines">@@ -812,10 +817,10 @@
</span><span class="cx"> UID:event1@ninevah.local
</span><span class="cx"> DTSTART:20140101T100000Z
</span><span class="cx"> DURATION:PT1H
</span><del>-ATTENDEE;CN=User 02;EMAIL=user02@example.com;RSVP=TRUE:urn:x-uid:10000000-0000-0000-0000-000000000002
-ATTENDEE;CN=Group 01;CUTYPE=X-SERVER-GROUP;EMAIL=group01@example.com;RSVP=TRUE:urn:x-uid:20000000-0000-0000-0000-000000000001
</del><ins>+ATTENDEE;CN=User 02;EMAIL=user02@example.com;RSVP=TRUE:urn:x-uid:user02
+ATTENDEE;CN=Group 01;CUTYPE=X-SERVER-GROUP;EMAIL=group01@example.com;RSVP=TRUE:urn:x-uid:group01
</ins><span class="cx"> CREATED:20060101T150000Z
</span><del>-ORGANIZER;CN=User 02;EMAIL=user02@example.com:urn:x-uid:10000000-0000-0000-0000-000000000002
</del><ins>+ORGANIZER;CN=User 02;EMAIL=user02@example.com:urn:x-uid:user02
</ins><span class="cx"> SEQUENCE:1
</span><span class="cx"> SUMMARY:event 1
</span><span class="cx"> END:VEVENT
</span><span class="lines">@@ -830,25 +835,24 @@
</span><span class="cx">         unpatchedExpandedMembers = CalendarDirectoryRecordMixin.expandedMembers
</span><span class="cx">         groupCacher = GroupCacher(self.transactionUnderTest().directoryService())
</span><span class="cx"> 
</span><del>-        calendar = yield self.calendarUnderTest(name=&quot;calendar&quot;, home=&quot;10000000-0000-0000-0000-000000000002&quot;)
</del><ins>+        calendar = yield self.calendarUnderTest(name=&quot;calendar&quot;, home=&quot;user02&quot;)
</ins><span class="cx">         vcalendar = Component.fromString(data_put_1)
</span><span class="cx">         yield calendar.createCalendarObjectWithName(&quot;data1.ics&quot;, vcalendar)
</span><span class="cx">         yield self.commit()
</span><span class="cx"> 
</span><span class="cx">         groupsToRefresh = yield groupCacher.groupsToRefresh(self.transactionUnderTest())
</span><span class="cx">         self.assertEqual(len(groupsToRefresh), 1)
</span><del>-        self.assertEqual(list(groupsToRefresh)[0], &quot;20000000-0000-0000-0000-000000000001&quot;)
</del><ins>+        self.assertEqual(list(groupsToRefresh)[0], &quot;group01&quot;)
</ins><span class="cx"> 
</span><del>-        wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), &quot;20000000-0000-0000-0000-000000000001&quot;)
</del><ins>+        wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), &quot;group01&quot;)
</ins><span class="cx">         yield self.commit()
</span><del>-        self.assertEqual(len(wps), 1)
-        yield JobItem.waitEmpty(self._sqlCalendarStore.newTransaction, reactor, 60)
</del><ins>+        self.assertEqual(len(wps), 0)
</ins><span class="cx"> 
</span><del>-        cobj = yield self.calendarObjectUnderTest(name=&quot;data1.ics&quot;, calendar_name=&quot;calendar&quot;, home=&quot;10000000-0000-0000-0000-000000000002&quot;)
</del><ins>+        cobj = yield self.calendarObjectUnderTest(name=&quot;data1.ics&quot;, calendar_name=&quot;calendar&quot;, home=&quot;user02&quot;)
</ins><span class="cx">         vcalendar = yield cobj.component()
</span><span class="cx">         self.assertEqual(normalize_iCalStr(vcalendar), normalize_iCalStr(data_get_1))
</span><span class="cx"> 
</span><del>-        yield self._verifyObjectResourceCount(&quot;10000000-0000-0000-0000-000000000001&quot;, 1)
</del><ins>+        yield self._verifyObjectResourceCount(&quot;user01&quot;, 1)
</ins><span class="cx"> 
</span><span class="cx">         vcalendar = Component.fromString(data_put_2)
</span><span class="cx">         yield cobj.setComponent(vcalendar)
</span><span class="lines">@@ -856,11 +860,11 @@
</span><span class="cx"> 
</span><span class="cx">         self.patch(CalendarDirectoryRecordMixin, &quot;expandedMembers&quot;, expandedMembers)
</span><span class="cx"> 
</span><del>-        cobj = yield self.calendarObjectUnderTest(name=&quot;data1.ics&quot;, calendar_name=&quot;calendar&quot;, home=&quot;10000000-0000-0000-0000-000000000002&quot;)
</del><ins>+        cobj = yield self.calendarObjectUnderTest(name=&quot;data1.ics&quot;, calendar_name=&quot;calendar&quot;, home=&quot;user02&quot;)
</ins><span class="cx">         vcalendar = yield cobj.component()
</span><span class="cx">         self.assertEqual(normalize_iCalStr(vcalendar), normalize_iCalStr(data_get_2))
</span><span class="cx"> 
</span><del>-        wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), &quot;20000000-0000-0000-0000-000000000001&quot;)
</del><ins>+        wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), &quot;group01&quot;)
</ins><span class="cx">         self.assertEqual(len(wps), 0)
</span><span class="cx">         yield self.commit()
</span><span class="cx">         yield JobItem.waitEmpty(self._sqlCalendarStore.newTransaction, reactor, 60)
</span><span class="lines">@@ -871,7 +875,7 @@
</span><span class="cx">         (
</span><span class="cx">             groupID, _ignore_name, _ignore_membershipHash, _ignore_modDate,
</span><span class="cx">             _ignore_extant
</span><del>-        ) = yield self.transactionUnderTest().groupByUID(&quot;20000000-0000-0000-0000-000000000001&quot;)
</del><ins>+        ) = yield self.transactionUnderTest().groupByUID(&quot;group01&quot;)
</ins><span class="cx">         ga = schema.GROUP_ATTENDEE
</span><span class="cx">         yield Insert({
</span><span class="cx">                 ga.RESOURCE_ID: cobj._resourceID,
</span><span class="lines">@@ -879,17 +883,17 @@
</span><span class="cx">                 ga.MEMBERSHIP_HASH: (-1),
</span><span class="cx">             }
</span><span class="cx">         ).on(self.transactionUnderTest())
</span><del>-        wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), &quot;20000000-0000-0000-0000-000000000001&quot;)
</del><ins>+        wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), &quot;group01&quot;)
</ins><span class="cx">         self.assertEqual(len(wps), 1)
</span><span class="cx">         yield self.commit()
</span><span class="cx">         yield JobItem.waitEmpty(self._sqlCalendarStore.newTransaction, reactor, 60)
</span><span class="cx"> 
</span><del>-        cobj = yield self.calendarObjectUnderTest(name=&quot;data1.ics&quot;, calendar_name=&quot;calendar&quot;, home=&quot;10000000-0000-0000-0000-000000000002&quot;)
</del><ins>+        cobj = yield self.calendarObjectUnderTest(name=&quot;data1.ics&quot;, calendar_name=&quot;calendar&quot;, home=&quot;user02&quot;)
</ins><span class="cx">         vcalendar = yield cobj.component()
</span><span class="cx">         self.assertEqual(normalize_iCalStr(vcalendar), normalize_iCalStr(data_get_2))
</span><span class="cx"> 
</span><span class="cx">         '''
</span><del>-        cal = yield self.calendarUnderTest(name=&quot;calendar&quot;, home=&quot;10000000-0000-0000-0000-000000000001&quot;)
</del><ins>+        cal = yield self.calendarUnderTest(name=&quot;calendar&quot;, home=&quot;user01&quot;)
</ins><span class="cx">         cobjs = yield cal.objectResources()
</span><span class="cx">         for cobj in cobjs:
</span><span class="cx">             print(&quot;comp = %s&quot; % ((yield cobj.componentForUser())))
</span><span class="lines">@@ -955,11 +959,11 @@
</span><span class="cx"> UID:event1@ninevah.local
</span><span class="cx"> DTSTART:20120101T100000Z
</span><span class="cx"> DURATION:PT1H
</span><del>-ATTENDEE;CN=User 02;EMAIL=user02@example.com;RSVP=TRUE:urn:x-uid:10000000-0000-0000-0000-000000000002
-ATTENDEE;CN=Group 01;CUTYPE=X-SERVER-GROUP;EMAIL=group01@example.com;RSVP=TRUE:urn:x-uid:20000000-0000-0000-0000-000000000001
-ATTENDEE;CN=User 01;EMAIL=user01@example.com;MEMBER=&quot;urn:x-uid:20000000-0000-0000-0000-000000000001&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:10000000-0000-0000-0000-000000000001
</del><ins>+ATTENDEE;CN=User 02;EMAIL=user02@example.com;RSVP=TRUE:urn:x-uid:user02
+ATTENDEE;CN=Group 01;CUTYPE=X-SERVER-GROUP;EMAIL=group01@example.com;RSVP=TRUE:urn:x-uid:group01
+ATTENDEE;CN=User 01;EMAIL=user01@example.com;MEMBER=&quot;urn:x-uid:group01&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:user01
</ins><span class="cx"> CREATED:20060101T150000Z
</span><del>-ORGANIZER;CN=User 02;EMAIL=user02@example.com:urn:x-uid:10000000-0000-0000-0000-000000000002
</del><ins>+ORGANIZER;CN=User 02;EMAIL=user02@example.com:urn:x-uid:user02
</ins><span class="cx"> RRULE:FREQ=DAILY;UNTIL=20240101T100000
</span><span class="cx"> SUMMARY:event 1
</span><span class="cx"> END:VEVENT
</span><span class="lines">@@ -974,10 +978,10 @@
</span><span class="cx"> UID:event1@ninevah.local
</span><span class="cx"> DTSTART:20120101T100000Z
</span><span class="cx"> DURATION:PT1H
</span><del>-ATTENDEE;CN=User 02;EMAIL=user02@example.com;RSVP=TRUE:urn:x-uid:10000000-0000-0000-0000-000000000002
-ATTENDEE;CN=Group 01;CUTYPE=X-SERVER-GROUP;EMAIL=group01@example.com;RSVP=TRUE:urn:x-uid:20000000-0000-0000-0000-000000000001
</del><ins>+ATTENDEE;CN=User 02;EMAIL=user02@example.com;RSVP=TRUE:urn:x-uid:user02
+ATTENDEE;CN=Group 01;CUTYPE=X-SERVER-GROUP;EMAIL=group01@example.com;RSVP=TRUE:urn:x-uid:group01
</ins><span class="cx"> CREATED:20060101T150000Z
</span><del>-ORGANIZER;CN=User 02;EMAIL=user02@example.com:urn:x-uid:10000000-0000-0000-0000-000000000002
</del><ins>+ORGANIZER;CN=User 02;EMAIL=user02@example.com:urn:x-uid:user02
</ins><span class="cx"> RRULE:FREQ=DAILY;UNTIL=20140101T100000
</span><span class="cx"> SEQUENCE:1
</span><span class="cx"> SUMMARY:event 1
</span><span class="lines">@@ -993,25 +997,24 @@
</span><span class="cx">         unpatchedExpandedMembers = CalendarDirectoryRecordMixin.expandedMembers
</span><span class="cx">         groupCacher = GroupCacher(self.transactionUnderTest().directoryService())
</span><span class="cx"> 
</span><del>-        calendar = yield self.calendarUnderTest(name=&quot;calendar&quot;, home=&quot;10000000-0000-0000-0000-000000000002&quot;)
</del><ins>+        calendar = yield self.calendarUnderTest(name=&quot;calendar&quot;, home=&quot;user02&quot;)
</ins><span class="cx">         vcalendar = Component.fromString(data_put_1)
</span><span class="cx">         yield calendar.createCalendarObjectWithName(&quot;data1.ics&quot;, vcalendar)
</span><span class="cx">         yield self.commit()
</span><span class="cx"> 
</span><span class="cx">         groupsToRefresh = yield groupCacher.groupsToRefresh(self.transactionUnderTest())
</span><span class="cx">         self.assertEqual(len(groupsToRefresh), 1)
</span><del>-        self.assertEqual(list(groupsToRefresh)[0], &quot;20000000-0000-0000-0000-000000000001&quot;)
</del><ins>+        self.assertEqual(list(groupsToRefresh)[0], &quot;group01&quot;)
</ins><span class="cx"> 
</span><del>-        wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), &quot;20000000-0000-0000-0000-000000000001&quot;)
</del><ins>+        wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), &quot;group01&quot;)
</ins><span class="cx">         yield self.commit()
</span><del>-        self.assertEqual(len(wps), 1)
-        yield JobItem.waitEmpty(self._sqlCalendarStore.newTransaction, reactor, 60)
</del><ins>+        self.assertEqual(len(wps), 0)
</ins><span class="cx"> 
</span><del>-        cobj = yield self.calendarObjectUnderTest(name=&quot;data1.ics&quot;, calendar_name=&quot;calendar&quot;, home=&quot;10000000-0000-0000-0000-000000000002&quot;)
</del><ins>+        cobj = yield self.calendarObjectUnderTest(name=&quot;data1.ics&quot;, calendar_name=&quot;calendar&quot;, home=&quot;user02&quot;)
</ins><span class="cx">         vcalendar = yield cobj.component()
</span><span class="cx">         self.assertEqual(normalize_iCalStr(vcalendar), normalize_iCalStr(data_get_1))
</span><span class="cx"> 
</span><del>-        yield self._verifyObjectResourceCount(&quot;10000000-0000-0000-0000-000000000001&quot;, 1)
</del><ins>+        yield self._verifyObjectResourceCount(&quot;user01&quot;, 1)
</ins><span class="cx"> 
</span><span class="cx">         vcalendar = Component.fromString(data_put_2)
</span><span class="cx">         yield cobj.setComponent(vcalendar)
</span><span class="lines">@@ -1019,11 +1022,11 @@
</span><span class="cx"> 
</span><span class="cx">         self.patch(CalendarDirectoryRecordMixin, &quot;expandedMembers&quot;, expandedMembers)
</span><span class="cx"> 
</span><del>-        cobj = yield self.calendarObjectUnderTest(name=&quot;data1.ics&quot;, calendar_name=&quot;calendar&quot;, home=&quot;10000000-0000-0000-0000-000000000002&quot;)
</del><ins>+        cobj = yield self.calendarObjectUnderTest(name=&quot;data1.ics&quot;, calendar_name=&quot;calendar&quot;, home=&quot;user02&quot;)
</ins><span class="cx">         vcalendar = yield cobj.component()
</span><span class="cx">         self.assertEqual(normalize_iCalStr(vcalendar), normalize_iCalStr(data_get_2))
</span><span class="cx"> 
</span><del>-        wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), &quot;20000000-0000-0000-0000-000000000001&quot;)
</del><ins>+        wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), &quot;group01&quot;)
</ins><span class="cx">         if len(wps): # This is needed because the test currently fails and does actually create job items we have to wait for
</span><span class="cx">             yield self.commit()
</span><span class="cx">             yield JobItem.waitEmpty(self._sqlCalendarStore.newTransaction, reactor, 60)
</span><span class="lines">@@ -1035,7 +1038,7 @@
</span><span class="cx">         (
</span><span class="cx">             groupID, _ignore_name, _ignore_membershipHash, _ignore_modDate,
</span><span class="cx">             _ignore_extant
</span><del>-        ) = yield self.transactionUnderTest().groupByUID(&quot;20000000-0000-0000-0000-000000000001&quot;)
</del><ins>+        ) = yield self.transactionUnderTest().groupByUID(&quot;group01&quot;)
</ins><span class="cx">         ga = schema.GROUP_ATTENDEE
</span><span class="cx">         yield Insert({
</span><span class="cx">                 ga.RESOURCE_ID: cobj._resourceID,
</span><span class="lines">@@ -1043,12 +1046,12 @@
</span><span class="cx">                 ga.MEMBERSHIP_HASH: (-1),
</span><span class="cx">             }
</span><span class="cx">         ).on(self.transactionUnderTest())
</span><del>-        wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), &quot;20000000-0000-0000-0000-000000000001&quot;)
</del><ins>+        wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), &quot;group01&quot;)
</ins><span class="cx">         self.assertEqual(len(wps), 1)
</span><span class="cx">         yield self.commit()
</span><span class="cx">         yield JobItem.waitEmpty(self._sqlCalendarStore.newTransaction, reactor, 60)
</span><span class="cx"> 
</span><del>-        cobj = yield self.calendarObjectUnderTest(name=&quot;data1.ics&quot;, calendar_name=&quot;calendar&quot;, home=&quot;10000000-0000-0000-0000-000000000002&quot;)
</del><ins>+        cobj = yield self.calendarObjectUnderTest(name=&quot;data1.ics&quot;, calendar_name=&quot;calendar&quot;, home=&quot;user02&quot;)
</ins><span class="cx">         vcalendar = yield cobj.component()
</span><span class="cx">         self.assertEqual(normalize_iCalStr(vcalendar), normalize_iCalStr(data_get_2))
</span><span class="cx"> 
</span><span class="lines">@@ -1085,11 +1088,11 @@
</span><span class="cx"> UID:event1@ninevah.local
</span><span class="cx"> DTSTART:20120101T100000Z
</span><span class="cx"> DURATION:PT1H
</span><del>-ATTENDEE;CN=User 02;EMAIL=user02@example.com;RSVP=TRUE:urn:x-uid:10000000-0000-0000-0000-000000000002
-ATTENDEE;CN=Group 01;CUTYPE=X-SERVER-GROUP;EMAIL=group01@example.com;RSVP=TRUE:urn:x-uid:20000000-0000-0000-0000-000000000001
-ATTENDEE;CN=User 01;EMAIL=user01@example.com;MEMBER=&quot;urn:x-uid:20000000-0000-0000-0000-000000000001&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:10000000-0000-0000-0000-000000000001
</del><ins>+ATTENDEE;CN=User 02;EMAIL=user02@example.com;RSVP=TRUE:urn:x-uid:user02
+ATTENDEE;CN=Group 01;CUTYPE=X-SERVER-GROUP;EMAIL=group01@example.com;RSVP=TRUE:urn:x-uid:group01
+ATTENDEE;CN=User 01;EMAIL=user01@example.com;MEMBER=&quot;urn:x-uid:group01&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:user01
</ins><span class="cx"> CREATED:20060101T150000Z
</span><del>-ORGANIZER;CN=User 02;EMAIL=user02@example.com:urn:x-uid:10000000-0000-0000-0000-000000000002
</del><ins>+ORGANIZER;CN=User 02;EMAIL=user02@example.com:urn:x-uid:user02
</ins><span class="cx"> RRULE:FREQ=DAILY;UNTIL=20240101T100000
</span><span class="cx"> SUMMARY:event 1
</span><span class="cx"> END:VEVENT
</span><span class="lines">@@ -1103,10 +1106,10 @@
</span><span class="cx"> BEGIN:VEVENT
</span><span class="cx"> UID:event1@ninevah.local
</span><span class="cx"> {start}DURATION:PT1H
</span><del>-ATTENDEE;CN=User 02;EMAIL=user02@example.com;RSVP=TRUE:urn:x-uid:10000000-0000-0000-0000-000000000002
-ATTENDEE;CN=Group 01;CUTYPE=X-SERVER-GROUP;EMAIL=group01@example.com;RSVP=TRUE:urn:x-uid:20000000-0000-0000-0000-000000000001
</del><ins>+ATTENDEE;CN=User 02;EMAIL=user02@example.com;RSVP=TRUE:urn:x-uid:user02
+ATTENDEE;CN=Group 01;CUTYPE=X-SERVER-GROUP;EMAIL=group01@example.com;RSVP=TRUE:urn:x-uid:group01
</ins><span class="cx"> CREATED:20060101T150000Z
</span><del>-ORGANIZER;CN=User 02;EMAIL=user02@example.com:urn:x-uid:10000000-0000-0000-0000-000000000002
</del><ins>+ORGANIZER;CN=User 02;EMAIL=user02@example.com:urn:x-uid:user02
</ins><span class="cx"> {relatedTo}RRULE:FREQ=DAILY;UNTIL=20240101T100000
</span><span class="cx"> SEQUENCE:2
</span><span class="cx"> SUMMARY:event 1
</span><span class="lines">@@ -1120,11 +1123,11 @@
</span><span class="cx"> BEGIN:VEVENT
</span><span class="cx"> {uid}DTSTART:20120101T100000Z
</span><span class="cx"> DURATION:PT1H
</span><del>-ATTENDEE;CN=User 02;EMAIL=user02@example.com;RSVP=TRUE:urn:x-uid:10000000-0000-0000-0000-000000000002
-ATTENDEE;CN=Group 01;CUTYPE=X-SERVER-GROUP;EMAIL=group01@example.com;RSVP=TRUE:urn:x-uid:20000000-0000-0000-0000-000000000001
-ATTENDEE;CN=User 01;EMAIL=user01@example.com;MEMBER=&quot;urn:x-uid:20000000-0000-0000-0000-000000000001&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:10000000-0000-0000-0000-000000000001
</del><ins>+ATTENDEE;CN=User 02;EMAIL=user02@example.com;RSVP=TRUE:urn:x-uid:user02
+ATTENDEE;CN=Group 01;CUTYPE=X-SERVER-GROUP;EMAIL=group01@example.com;RSVP=TRUE:urn:x-uid:group01
+ATTENDEE;CN=User 01;EMAIL=user01@example.com;MEMBER=&quot;urn:x-uid:group01&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:user01
</ins><span class="cx"> CREATED:20060101T150000Z
</span><del>-ORGANIZER;CN=User 02;EMAIL=user02@example.com:urn:x-uid:10000000-0000-0000-0000-000000000002
</del><ins>+ORGANIZER;CN=User 02;EMAIL=user02@example.com:urn:x-uid:user02
</ins><span class="cx"> {relatedTo}{rule}SEQUENCE:1
</span><span class="cx"> SUMMARY:event 1
</span><span class="cx"> END:VEVENT
</span><span class="lines">@@ -1138,25 +1141,25 @@
</span><span class="cx"> 
</span><span class="cx">         groupCacher = GroupCacher(self.transactionUnderTest().directoryService())
</span><span class="cx"> 
</span><del>-        calendar = yield self.calendarUnderTest(name=&quot;calendar&quot;, home=&quot;10000000-0000-0000-0000-000000000002&quot;)
</del><ins>+        calendar = yield self.calendarUnderTest(name=&quot;calendar&quot;, home=&quot;user02&quot;)
</ins><span class="cx">         vcalendar = Component.fromString(data_put_1)
</span><span class="cx">         yield calendar.createCalendarObjectWithName(&quot;data1.ics&quot;, vcalendar)
</span><span class="cx">         yield self.commit()
</span><span class="cx"> 
</span><del>-        cobj = yield self.calendarObjectUnderTest(name=&quot;data1.ics&quot;, calendar_name=&quot;calendar&quot;, home=&quot;10000000-0000-0000-0000-000000000002&quot;)
</del><ins>+        cobj = yield self.calendarObjectUnderTest(name=&quot;data1.ics&quot;, calendar_name=&quot;calendar&quot;, home=&quot;user02&quot;)
</ins><span class="cx">         vcalendar = yield cobj.component()
</span><span class="cx">         self.assertEqual(normalize_iCalStr(vcalendar), normalize_iCalStr(data_get_1))
</span><span class="cx"> 
</span><del>-        yield self._verifyObjectResourceCount(&quot;10000000-0000-0000-0000-000000000001&quot;, 1)
</del><ins>+        yield self._verifyObjectResourceCount(&quot;user01&quot;, 1)
</ins><span class="cx"> 
</span><span class="cx">         self.patch(CalendarDirectoryRecordMixin, &quot;expandedMembers&quot;, expandedMembers)
</span><span class="cx"> 
</span><del>-        wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), &quot;20000000-0000-0000-0000-000000000001&quot;)
</del><ins>+        wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), &quot;group01&quot;)
</ins><span class="cx">         yield self.commit()
</span><span class="cx">         self.assertEqual(len(wps), 1)
</span><span class="cx">         yield JobItem.waitEmpty(self._sqlCalendarStore.newTransaction, reactor, 60)
</span><span class="cx"> 
</span><del>-        cal = yield self.calendarUnderTest(name=&quot;calendar&quot;, home=&quot;10000000-0000-0000-0000-000000000002&quot;)
</del><ins>+        cal = yield self.calendarUnderTest(name=&quot;calendar&quot;, home=&quot;user02&quot;)
</ins><span class="cx">         cobjs = yield cal.objectResources()
</span><span class="cx">         for cobj in cobjs:
</span><span class="cx">             vcalendar = yield cobj.component()
</span><span class="lines">@@ -1193,7 +1196,7 @@
</span><span class="cx"> 
</span><span class="cx">         #TODO: add some meaningful test
</span><span class="cx">         '''
</span><del>-        cal = yield self.calendarUnderTest(name=&quot;calendar&quot;, home=&quot;10000000-0000-0000-0000-000000000001&quot;)
</del><ins>+        cal = yield self.calendarUnderTest(name=&quot;calendar&quot;, home=&quot;user01&quot;)
</ins><span class="cx">         cobjs = yield cal.objectResources()
</span><span class="cx">         for cobj in cobjs:
</span><span class="cx">             vcalendar = yield cobj.component()
</span><span class="lines">@@ -1232,10 +1235,10 @@
</span><span class="cx"> UID:event1@ninevah.local
</span><span class="cx"> DTSTART:20120101T100000Z
</span><span class="cx"> DURATION:PT1H
</span><del>-ATTENDEE;CN=User 02;EMAIL=user02@example.com;RSVP=TRUE:urn:x-uid:10000000-0000-0000-0000-000000000002
-ATTENDEE;CN=Group 01;CUTYPE=X-SERVER-GROUP;EMAIL=group01@example.com;RSVP=TRUE:urn:x-uid:20000000-0000-0000-0000-000000000001
</del><ins>+ATTENDEE;CN=User 02;EMAIL=user02@example.com;RSVP=TRUE:urn:x-uid:user02
+ATTENDEE;CN=Group 01;CUTYPE=X-SERVER-GROUP;EMAIL=group01@example.com;RSVP=TRUE:urn:x-uid:group01
</ins><span class="cx"> CREATED:20060101T150000Z
</span><del>-ORGANIZER;CN=User 02;EMAIL=user02@example.com:urn:x-uid:10000000-0000-0000-0000-000000000002
</del><ins>+ORGANIZER;CN=User 02;EMAIL=user02@example.com:urn:x-uid:user02
</ins><span class="cx"> RRULE:FREQ=DAILY;UNTIL=20240101T100000
</span><span class="cx"> SUMMARY:event 1
</span><span class="cx"> END:VEVENT
</span><span class="lines">@@ -1249,11 +1252,11 @@
</span><span class="cx"> BEGIN:VEVENT
</span><span class="cx"> UID:event1@ninevah.local
</span><span class="cx"> {start}DURATION:PT1H
</span><del>-ATTENDEE;CN=User 02;EMAIL=user02@example.com;RSVP=TRUE:urn:x-uid:10000000-0000-0000-0000-000000000002
-ATTENDEE;CN=Group 01;CUTYPE=X-SERVER-GROUP;EMAIL=group01@example.com;RSVP=TRUE:urn:x-uid:20000000-0000-0000-0000-000000000001
-ATTENDEE;CN=User 01;EMAIL=user01@example.com;MEMBER=&quot;urn:x-uid:20000000-0000-0000-0000-000000000001&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:10000000-0000-0000-0000-000000000001
</del><ins>+ATTENDEE;CN=User 02;EMAIL=user02@example.com;RSVP=TRUE:urn:x-uid:user02
+ATTENDEE;CN=Group 01;CUTYPE=X-SERVER-GROUP;EMAIL=group01@example.com;RSVP=TRUE:urn:x-uid:group01
+ATTENDEE;CN=User 01;EMAIL=user01@example.com;MEMBER=&quot;urn:x-uid:group01&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:user01
</ins><span class="cx"> CREATED:20060101T150000Z
</span><del>-ORGANIZER;CN=User 02;EMAIL=user02@example.com:urn:x-uid:10000000-0000-0000-0000-000000000002
</del><ins>+ORGANIZER;CN=User 02;EMAIL=user02@example.com:urn:x-uid:user02
</ins><span class="cx"> {relatedTo}RRULE:FREQ=DAILY;UNTIL=20240101T100000
</span><span class="cx"> SEQUENCE:2
</span><span class="cx"> SUMMARY:event 1
</span><span class="lines">@@ -1267,10 +1270,10 @@
</span><span class="cx"> BEGIN:VEVENT
</span><span class="cx"> {uid}DTSTART:20120101T100000Z
</span><span class="cx"> DURATION:PT1H
</span><del>-ATTENDEE;CN=User 02;EMAIL=user02@example.com;RSVP=TRUE:urn:x-uid:10000000-0000-0000-0000-000000000002
-ATTENDEE;CN=Group 01;CUTYPE=X-SERVER-GROUP;EMAIL=group01@example.com;RSVP=TRUE:urn:x-uid:20000000-0000-0000-0000-000000000001
</del><ins>+ATTENDEE;CN=User 02;EMAIL=user02@example.com;RSVP=TRUE:urn:x-uid:user02
+ATTENDEE;CN=Group 01;CUTYPE=X-SERVER-GROUP;EMAIL=group01@example.com;RSVP=TRUE:urn:x-uid:group01
</ins><span class="cx"> CREATED:20060101T150000Z
</span><del>-ORGANIZER;CN=User 02;EMAIL=user02@example.com:urn:x-uid:10000000-0000-0000-0000-000000000002
</del><ins>+ORGANIZER;CN=User 02;EMAIL=user02@example.com:urn:x-uid:user02
</ins><span class="cx"> {relatedTo}{rule}SEQUENCE:1
</span><span class="cx"> SUMMARY:event 1
</span><span class="cx"> END:VEVENT
</span><span class="lines">@@ -1287,25 +1290,25 @@
</span><span class="cx"> 
</span><span class="cx">         groupCacher = GroupCacher(self.transactionUnderTest().directoryService())
</span><span class="cx"> 
</span><del>-        calendar = yield self.calendarUnderTest(name=&quot;calendar&quot;, home=&quot;10000000-0000-0000-0000-000000000002&quot;)
</del><ins>+        calendar = yield self.calendarUnderTest(name=&quot;calendar&quot;, home=&quot;user02&quot;)
</ins><span class="cx">         vcalendar = Component.fromString(data_put_1)
</span><span class="cx">         yield calendar.createCalendarObjectWithName(&quot;data1.ics&quot;, vcalendar)
</span><span class="cx">         yield self.commit()
</span><span class="cx"> 
</span><del>-        cobj = yield self.calendarObjectUnderTest(name=&quot;data1.ics&quot;, calendar_name=&quot;calendar&quot;, home=&quot;10000000-0000-0000-0000-000000000002&quot;)
</del><ins>+        cobj = yield self.calendarObjectUnderTest(name=&quot;data1.ics&quot;, calendar_name=&quot;calendar&quot;, home=&quot;user02&quot;)
</ins><span class="cx">         vcalendar = yield cobj.component()
</span><span class="cx">         self.assertEqual(normalize_iCalStr(vcalendar), normalize_iCalStr(data_get_1))
</span><span class="cx"> 
</span><del>-        yield self._verifyObjectResourceCount(&quot;10000000-0000-0000-0000-000000000001&quot;, 0)
</del><ins>+        yield self._verifyObjectResourceCount(&quot;user01&quot;, 0)
</ins><span class="cx"> 
</span><span class="cx">         self.patch(CalendarDirectoryRecordMixin, &quot;expandedMembers&quot;, unpatchedExpandedMembers)
</span><span class="cx"> 
</span><del>-        wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), &quot;20000000-0000-0000-0000-000000000001&quot;)
</del><ins>+        wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), &quot;group01&quot;)
</ins><span class="cx">         yield self.commit()
</span><span class="cx">         self.assertEqual(len(wps), 1)
</span><span class="cx">         yield JobItem.waitEmpty(self._sqlCalendarStore.newTransaction, reactor, 60)
</span><span class="cx"> 
</span><del>-        cal = yield self.calendarUnderTest(name=&quot;calendar&quot;, home=&quot;10000000-0000-0000-0000-000000000002&quot;)
</del><ins>+        cal = yield self.calendarUnderTest(name=&quot;calendar&quot;, home=&quot;user02&quot;)
</ins><span class="cx">         cobjs = yield cal.objectResources()
</span><span class="cx">         for cobj in cobjs:
</span><span class="cx">             vcalendar = yield cobj.component()
</span><span class="lines">@@ -1340,10 +1343,10 @@
</span><span class="cx">                     )
</span><span class="cx">                 )
</span><span class="cx"> 
</span><del>-        yield self._verifyObjectResourceCount(&quot;10000000-0000-0000-0000-000000000001&quot;, 1)
</del><ins>+        yield self._verifyObjectResourceCount(&quot;user01&quot;, 1)
</ins><span class="cx">         #TODO: add some meaningful test
</span><span class="cx">         '''
</span><del>-        cal = yield self.calendarUnderTest(name=&quot;calendar&quot;, home=&quot;10000000-0000-0000-0000-000000000001&quot;)
</del><ins>+        cal = yield self.calendarUnderTest(name=&quot;calendar&quot;, home=&quot;user01&quot;)
</ins><span class="cx">         cobjs = yield cal.objectResources()
</span><span class="cx">         for cobj in cobjs:
</span><span class="cx">             vcalendar = yield cobj.component()
</span><span class="lines">@@ -1358,13 +1361,13 @@
</span><span class="cx">         of those groups is removed
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx"> 
</span><del>-        yield self._verifyObjectResourceCount(&quot;10000000-0000-0000-0000-000000000006&quot;, 0)
-        yield self._verifyObjectResourceCount(&quot;10000000-0000-0000-0000-000000000007&quot;, 0)
-        yield self._verifyObjectResourceCount(&quot;10000000-0000-0000-0000-000000000008&quot;, 0)
-        yield self._verifyObjectResourceCount(&quot;10000000-0000-0000-0000-000000000009&quot;, 0)
-        yield self._verifyObjectResourceCount(&quot;10000000-0000-0000-0000-000000000010&quot;, 0)
</del><ins>+        yield self._verifyObjectResourceCount(&quot;user06&quot;, 0)
+        yield self._verifyObjectResourceCount(&quot;user07&quot;, 0)
+        yield self._verifyObjectResourceCount(&quot;user08&quot;, 0)
+        yield self._verifyObjectResourceCount(&quot;user09&quot;, 0)
+        yield self._verifyObjectResourceCount(&quot;user10&quot;, 0)
</ins><span class="cx"> 
</span><del>-        calendar = yield self.calendarUnderTest(name=&quot;calendar&quot;, home=&quot;10000000-0000-0000-0000-000000000001&quot;)
</del><ins>+        calendar = yield self.calendarUnderTest(name=&quot;calendar&quot;, home=&quot;user01&quot;)
</ins><span class="cx"> 
</span><span class="cx">         data_put_1 = &quot;&quot;&quot;BEGIN:VCALENDAR
</span><span class="cx"> CALSCALE:GREGORIAN
</span><span class="lines">@@ -1393,16 +1396,16 @@
</span><span class="cx"> UID:event1@ninevah.local
</span><span class="cx"> DTSTART:20240101T100000Z
</span><span class="cx"> DURATION:PT1H
</span><del>-ATTENDEE;CN=User 01;EMAIL=user01@example.com;RSVP=TRUE:urn:x-uid:10000000-0000-0000-0000-000000000001
-ATTENDEE;CN=Group 01;CUTYPE=X-SERVER-GROUP;EMAIL=group01@example.com;RSVP=TRUE:urn:x-uid:20000000-0000-0000-0000-000000000001
-ATTENDEE;CN=Group 02;CUTYPE=X-SERVER-GROUP;EMAIL=group02@example.com;RSVP=TRUE:urn:x-uid:20000000-0000-0000-0000-000000000002
-ATTENDEE;CN=Group 03;CUTYPE=X-SERVER-GROUP;EMAIL=group03@example.com;RSVP=TRUE:urn:x-uid:20000000-0000-0000-0000-000000000003
-ATTENDEE;CN=User 06;EMAIL=user06@example.com;MEMBER=&quot;urn:x-uid:20000000-0000-0000-0000-000000000002&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:10000000-0000-0000-0000-000000000006
-ATTENDEE;CN=User 07;EMAIL=user07@example.com;MEMBER=&quot;urn:x-uid:20000000-0000-0000-0000-000000000002&quot;,&quot;urn:x-uid:20000000-0000-0000-0000-000000000003&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:10000000-0000-0000-0000-000000000007
-ATTENDEE;CN=User 08;EMAIL=user08@example.com;MEMBER=&quot;urn:x-uid:20000000-0000-0000-0000-000000000002&quot;,&quot;urn:x-uid:20000000-0000-0000-0000-000000000003&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:10000000-0000-0000-0000-000000000008
-ATTENDEE;CN=User 09;EMAIL=user09@example.com;MEMBER=&quot;urn:x-uid:20000000-0000-0000-0000-000000000003&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:10000000-0000-0000-0000-000000000009
</del><ins>+ATTENDEE;CN=User 01;EMAIL=user01@example.com;RSVP=TRUE:urn:x-uid:user01
+ATTENDEE;CN=Group 01;CUTYPE=X-SERVER-GROUP;EMAIL=group01@example.com;RSVP=TRUE:urn:x-uid:group01
+ATTENDEE;CN=Group 02;CUTYPE=X-SERVER-GROUP;EMAIL=group02@example.com;RSVP=TRUE:urn:x-uid:group02
+ATTENDEE;CN=Group 03;CUTYPE=X-SERVER-GROUP;EMAIL=group03@example.com;RSVP=TRUE:urn:x-uid:group03
+ATTENDEE;CN=User 06;EMAIL=user06@example.com;MEMBER=&quot;urn:x-uid:group02&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:user06
+ATTENDEE;CN=User 07;EMAIL=user07@example.com;MEMBER=&quot;urn:x-uid:group02&quot;,&quot;urn:x-uid:group03&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:user07
+ATTENDEE;CN=User 08;EMAIL=user08@example.com;MEMBER=&quot;urn:x-uid:group02&quot;,&quot;urn:x-uid:group03&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:user08
+ATTENDEE;CN=User 09;EMAIL=user09@example.com;MEMBER=&quot;urn:x-uid:group03&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:user09
</ins><span class="cx"> CREATED:20060101T150000Z
</span><del>-ORGANIZER;CN=User 01;EMAIL=user01@example.com:urn:x-uid:10000000-0000-0000-0000-000000000001
</del><ins>+ORGANIZER;CN=User 01;EMAIL=user01@example.com:urn:x-uid:user01
</ins><span class="cx"> SUMMARY:event 1
</span><span class="cx"> END:VEVENT
</span><span class="cx"> END:VCALENDAR&quot;&quot;&quot;
</span><span class="lines">@@ -1415,15 +1418,15 @@
</span><span class="cx"> UID:event1@ninevah.local
</span><span class="cx"> DTSTART:20240101T100000Z
</span><span class="cx"> DURATION:PT1H
</span><del>-ATTENDEE;CN=User 01;EMAIL=user01@example.com;RSVP=TRUE:urn:x-uid:10000000-0000-0000-0000-000000000001
-ATTENDEE;CN=Group 01;CUTYPE=X-SERVER-GROUP;EMAIL=group01@example.com;RSVP=TRUE:urn:x-uid:20000000-0000-0000-0000-000000000001
-ATTENDEE;CN=Group 02;CUTYPE=X-SERVER-GROUP;EMAIL=group02@example.com;RSVP=TRUE:urn:x-uid:20000000-0000-0000-0000-000000000002
-ATTENDEE;CN=Group 03;CUTYPE=X-SERVER-GROUP;EMAIL=group03@example.com;RSVP=TRUE:urn:x-uid:20000000-0000-0000-0000-000000000003
-ATTENDEE;CN=User 07;EMAIL=user07@example.com;MEMBER=&quot;urn:x-uid:20000000-0000-0000-0000-000000000003&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:10000000-0000-0000-0000-000000000007
-ATTENDEE;CN=User 08;EMAIL=user08@example.com;MEMBER=&quot;urn:x-uid:20000000-0000-0000-0000-000000000003&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:10000000-0000-0000-0000-000000000008
-ATTENDEE;CN=User 09;EMAIL=user09@example.com;MEMBER=&quot;urn:x-uid:20000000-0000-0000-0000-000000000003&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:10000000-0000-0000-0000-000000000009
</del><ins>+ATTENDEE;CN=User 01;EMAIL=user01@example.com;RSVP=TRUE:urn:x-uid:user01
+ATTENDEE;CN=Group 01;CUTYPE=X-SERVER-GROUP;EMAIL=group01@example.com;RSVP=TRUE:urn:x-uid:group01
+ATTENDEE;CN=Group 02;CUTYPE=X-SERVER-GROUP;EMAIL=group02@example.com;RSVP=TRUE:urn:x-uid:group02
+ATTENDEE;CN=Group 03;CUTYPE=X-SERVER-GROUP;EMAIL=group03@example.com;RSVP=TRUE:urn:x-uid:group03
+ATTENDEE;CN=User 07;EMAIL=user07@example.com;MEMBER=&quot;urn:x-uid:group03&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:user07
+ATTENDEE;CN=User 08;EMAIL=user08@example.com;MEMBER=&quot;urn:x-uid:group03&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:user08
+ATTENDEE;CN=User 09;EMAIL=user09@example.com;MEMBER=&quot;urn:x-uid:group03&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:user09
</ins><span class="cx"> CREATED:20060101T150000Z
</span><del>-ORGANIZER;CN=User 01;EMAIL=user01@example.com:urn:x-uid:10000000-0000-0000-0000-000000000001
</del><ins>+ORGANIZER;CN=User 01;EMAIL=user01@example.com:urn:x-uid:user01
</ins><span class="cx"> SEQUENCE:1
</span><span class="cx"> SUMMARY:event 1
</span><span class="cx"> END:VEVENT
</span><span class="lines">@@ -1438,16 +1441,16 @@
</span><span class="cx"> UID:event1@ninevah.local
</span><span class="cx"> DTSTART:20240101T100000Z
</span><span class="cx"> DURATION:PT1H
</span><del>-ATTENDEE;CN=User 01;EMAIL=user01@example.com;RSVP=TRUE:urn:x-uid:10000000-0000-0000-0000-000000000001
-ATTENDEE;CN=Group 01;CUTYPE=X-SERVER-GROUP;EMAIL=group01@example.com;RSVP=TRUE:urn:x-uid:20000000-0000-0000-0000-000000000001
-ATTENDEE;CN=Group 02;CUTYPE=X-SERVER-GROUP;EMAIL=group02@example.com;RSVP=TRUE:urn:x-uid:20000000-0000-0000-0000-000000000002
-ATTENDEE;CN=Group 03;CUTYPE=X-SERVER-GROUP;EMAIL=group03@example.com;RSVP=TRUE:urn:x-uid:20000000-0000-0000-0000-000000000003
-ATTENDEE;CN=User 06;EMAIL=user06@example.com;MEMBER=&quot;urn:x-uid:20000000-0000-0000-0000-000000000002&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:10000000-0000-0000-0000-000000000006
-ATTENDEE;CN=User 07;EMAIL=user07@example.com;MEMBER=&quot;urn:x-uid:20000000-0000-0000-0000-000000000002&quot;,&quot;urn:x-uid:20000000-0000-0000-0000-000000000003&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:10000000-0000-0000-0000-000000000007
-ATTENDEE;CN=User 08;EMAIL=user08@example.com;MEMBER=&quot;urn:x-uid:20000000-0000-0000-0000-000000000002&quot;,&quot;urn:x-uid:20000000-0000-0000-0000-000000000003&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:10000000-0000-0000-0000-000000000008
-ATTENDEE;CN=User 09;EMAIL=user09@example.com;MEMBER=&quot;urn:x-uid:20000000-0000-0000-0000-000000000003&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:10000000-0000-0000-0000-000000000009
</del><ins>+ATTENDEE;CN=User 01;EMAIL=user01@example.com;RSVP=TRUE:urn:x-uid:user01
+ATTENDEE;CN=Group 01;CUTYPE=X-SERVER-GROUP;EMAIL=group01@example.com;RSVP=TRUE:urn:x-uid:group01
+ATTENDEE;CN=Group 02;CUTYPE=X-SERVER-GROUP;EMAIL=group02@example.com;RSVP=TRUE:urn:x-uid:group02
+ATTENDEE;CN=Group 03;CUTYPE=X-SERVER-GROUP;EMAIL=group03@example.com;RSVP=TRUE:urn:x-uid:group03
+ATTENDEE;CN=User 06;EMAIL=user06@example.com;MEMBER=&quot;urn:x-uid:group02&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:user06
+ATTENDEE;CN=User 07;EMAIL=user07@example.com;MEMBER=&quot;urn:x-uid:group02&quot;,&quot;urn:x-uid:group03&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:user07
+ATTENDEE;CN=User 08;EMAIL=user08@example.com;MEMBER=&quot;urn:x-uid:group02&quot;,&quot;urn:x-uid:group03&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:user08
+ATTENDEE;CN=User 09;EMAIL=user09@example.com;MEMBER=&quot;urn:x-uid:group03&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:user09
</ins><span class="cx"> CREATED:20060101T150000Z
</span><del>-ORGANIZER;CN=User 01;EMAIL=user01@example.com:urn:x-uid:10000000-0000-0000-0000-000000000001
</del><ins>+ORGANIZER;CN=User 01;EMAIL=user01@example.com:urn:x-uid:user01
</ins><span class="cx"> SEQUENCE:2
</span><span class="cx"> SUMMARY:event 1
</span><span class="cx"> END:VEVENT
</span><span class="lines">@@ -1458,7 +1461,7 @@
</span><span class="cx">         @inlineCallbacks
</span><span class="cx">         def recordWithUID(self, uid):
</span><span class="cx"> 
</span><del>-            if uid == &quot;20000000-0000-0000-0000-000000000002&quot;:
</del><ins>+            if uid == &quot;group02&quot;:
</ins><span class="cx">                 result = None
</span><span class="cx">             else:
</span><span class="cx">                 result = yield unpatchedRecordWithUID(self, uid)
</span><span class="lines">@@ -1468,42 +1471,41 @@
</span><span class="cx">         yield calendar.createCalendarObjectWithName(&quot;data1.ics&quot;, vcalendar)
</span><span class="cx">         yield self.commit()
</span><span class="cx"> 
</span><del>-        cobj = yield self.calendarObjectUnderTest(name=&quot;data1.ics&quot;, calendar_name=&quot;calendar&quot;, home=&quot;10000000-0000-0000-0000-000000000001&quot;)
</del><ins>+        cobj = yield self.calendarObjectUnderTest(name=&quot;data1.ics&quot;, calendar_name=&quot;calendar&quot;, home=&quot;user01&quot;)
</ins><span class="cx">         vcalendar = yield cobj.component()
</span><span class="cx">         self._assertICalStrEqual(vcalendar, data_get_1)
</span><span class="cx"> 
</span><del>-        yield self._verifyObjectResourceCount(&quot;10000000-0000-0000-0000-000000000006&quot;, 1)
-        yield self._verifyObjectResourceCount(&quot;10000000-0000-0000-0000-000000000007&quot;, 1)
-        yield self._verifyObjectResourceCount(&quot;10000000-0000-0000-0000-000000000008&quot;, 1)
-        yield self._verifyObjectResourceCount(&quot;10000000-0000-0000-0000-000000000009&quot;, 1)
</del><ins>+        yield self._verifyObjectResourceCount(&quot;user06&quot;, 1)
+        yield self._verifyObjectResourceCount(&quot;user07&quot;, 1)
+        yield self._verifyObjectResourceCount(&quot;user08&quot;, 1)
+        yield self._verifyObjectResourceCount(&quot;user09&quot;, 1)
</ins><span class="cx"> 
</span><span class="cx">         # cache group
</span><span class="cx">         groupCacher = GroupCacher(self.transactionUnderTest().directoryService())
</span><span class="cx">         groupsToRefresh = yield groupCacher.groupsToRefresh(self.transactionUnderTest())
</span><span class="cx">         self.assertEqual(len(groupsToRefresh), 3)
</span><span class="cx"> 
</span><del>-        wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), &quot;20000000-0000-0000-0000-000000000002&quot;)
</del><ins>+        wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), &quot;group02&quot;)
</ins><span class="cx">         yield self.commit()
</span><del>-        self.assertEqual(len(wps), 1)
-        yield JobItem.waitEmpty(self._sqlCalendarStore.newTransaction, reactor, 60)
</del><ins>+        self.assertEqual(len(wps), 0)
</ins><span class="cx"> 
</span><del>-        cobj = yield self.calendarObjectUnderTest(name=&quot;data1.ics&quot;, calendar_name=&quot;calendar&quot;, home=&quot;10000000-0000-0000-0000-000000000001&quot;)
</del><ins>+        cobj = yield self.calendarObjectUnderTest(name=&quot;data1.ics&quot;, calendar_name=&quot;calendar&quot;, home=&quot;user01&quot;)
</ins><span class="cx">         vcalendar = yield cobj.component()
</span><span class="cx">         self._assertICalStrEqual(vcalendar, data_get_1)
</span><span class="cx"> 
</span><span class="cx">         # remove group members run cacher again
</span><span class="cx">         self.patch(DirectoryService, &quot;recordWithUID&quot;, recordWithUID)
</span><span class="cx"> 
</span><del>-        wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), &quot;20000000-0000-0000-0000-000000000002&quot;)
</del><ins>+        wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), &quot;group02&quot;)
</ins><span class="cx">         yield self.commit()
</span><span class="cx">         self.assertEqual(len(wps), 1)
</span><span class="cx">         yield JobItem.waitEmpty(self._sqlCalendarStore.newTransaction, reactor, 60)
</span><span class="cx"> 
</span><del>-        cobj = yield self.calendarObjectUnderTest(name=&quot;data1.ics&quot;, calendar_name=&quot;calendar&quot;, home=&quot;10000000-0000-0000-0000-000000000001&quot;)
</del><ins>+        cobj = yield self.calendarObjectUnderTest(name=&quot;data1.ics&quot;, calendar_name=&quot;calendar&quot;, home=&quot;user01&quot;)
</ins><span class="cx">         vcalendar = yield cobj.component()
</span><span class="cx">         self._assertICalStrEqual(vcalendar, data_get_2)
</span><span class="cx"> 
</span><del>-        cal = yield self.calendarUnderTest(name=&quot;calendar&quot;, home=&quot;10000000-0000-0000-0000-000000000006&quot;)
</del><ins>+        cal = yield self.calendarUnderTest(name=&quot;calendar&quot;, home=&quot;user06&quot;)
</ins><span class="cx">         cobjs = yield cal.objectResources()
</span><span class="cx">         self.assertEqual(len(cobjs), 1)
</span><span class="cx">         comp = yield cobjs[0].componentForUser()
</span><span class="lines">@@ -1513,16 +1515,16 @@
</span><span class="cx">         # add group members back, run cacher
</span><span class="cx">         self.patch(DirectoryService, &quot;recordWithUID&quot;, unpatchedRecordWithUID)
</span><span class="cx"> 
</span><del>-        wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), &quot;20000000-0000-0000-0000-000000000002&quot;)
</del><ins>+        wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), &quot;group02&quot;)
</ins><span class="cx">         self.assertEqual(len(wps), 1)
</span><span class="cx">         yield self.commit()
</span><span class="cx">         yield JobItem.waitEmpty(self._sqlCalendarStore.newTransaction, reactor, 60)
</span><span class="cx"> 
</span><del>-        cobj = yield self.calendarObjectUnderTest(name=&quot;data1.ics&quot;, calendar_name=&quot;calendar&quot;, home=&quot;10000000-0000-0000-0000-000000000001&quot;)
</del><ins>+        cobj = yield self.calendarObjectUnderTest(name=&quot;data1.ics&quot;, calendar_name=&quot;calendar&quot;, home=&quot;user01&quot;)
</ins><span class="cx">         vcalendar = yield cobj.component()
</span><span class="cx">         self._assertICalStrEqual(vcalendar, data_get_3)
</span><span class="cx"> 
</span><del>-        cal = yield self.calendarUnderTest(name=&quot;calendar&quot;, home=&quot;10000000-0000-0000-0000-000000000006&quot;)
</del><ins>+        cal = yield self.calendarUnderTest(name=&quot;calendar&quot;, home=&quot;user06&quot;)
</ins><span class="cx">         cobjs = yield cal.objectResources()
</span><span class="cx">         self.assertEqual(len(cobjs), 1)
</span><span class="cx">         comp = yield cobjs[0].componentForUser()
</span><span class="lines">@@ -1538,13 +1540,13 @@
</span><span class="cx">         those groups is removed
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx"> 
</span><del>-        yield self._verifyObjectResourceCount(&quot;10000000-0000-0000-0000-000000000006&quot;, 0)
-        yield self._verifyObjectResourceCount(&quot;10000000-0000-0000-0000-000000000007&quot;, 0)
-        yield self._verifyObjectResourceCount(&quot;10000000-0000-0000-0000-000000000008&quot;, 0)
-        yield self._verifyObjectResourceCount(&quot;10000000-0000-0000-0000-000000000009&quot;, 0)
-        yield self._verifyObjectResourceCount(&quot;10000000-0000-0000-0000-000000000010&quot;, 0)
</del><ins>+        yield self._verifyObjectResourceCount(&quot;user06&quot;, 0)
+        yield self._verifyObjectResourceCount(&quot;user07&quot;, 0)
+        yield self._verifyObjectResourceCount(&quot;user08&quot;, 0)
+        yield self._verifyObjectResourceCount(&quot;user09&quot;, 0)
+        yield self._verifyObjectResourceCount(&quot;user10&quot;, 0)
</ins><span class="cx"> 
</span><del>-        calendar = yield self.calendarUnderTest(name=&quot;calendar&quot;, home=&quot;10000000-0000-0000-0000-000000000001&quot;)
</del><ins>+        calendar = yield self.calendarUnderTest(name=&quot;calendar&quot;, home=&quot;user01&quot;)
</ins><span class="cx"> 
</span><span class="cx">         data_put_1 = &quot;&quot;&quot;BEGIN:VCALENDAR
</span><span class="cx"> CALSCALE:GREGORIAN
</span><span class="lines">@@ -1572,15 +1574,15 @@
</span><span class="cx"> UID:event1@ninevah.local
</span><span class="cx"> DTSTART:20240101T100000Z
</span><span class="cx"> DURATION:PT1H
</span><del>-ATTENDEE;CN=User 01;EMAIL=user01@example.com;RSVP=TRUE:urn:x-uid:10000000-0000-0000-0000-000000000001
-ATTENDEE;CN=Group 02;CUTYPE=X-SERVER-GROUP;EMAIL=group02@example.com;RSVP=TRUE:urn:x-uid:20000000-0000-0000-0000-000000000002
-ATTENDEE;CN=Group 03;CUTYPE=X-SERVER-GROUP;EMAIL=group03@example.com;RSVP=TRUE:urn:x-uid:20000000-0000-0000-0000-000000000003
-ATTENDEE;CN=User 06;EMAIL=user06@example.com;MEMBER=&quot;urn:x-uid:20000000-0000-0000-0000-000000000002&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:10000000-0000-0000-0000-000000000006
-ATTENDEE;CN=User 07;EMAIL=user07@example.com;MEMBER=&quot;urn:x-uid:20000000-0000-0000-0000-000000000002&quot;,&quot;urn:x-uid:20000000-0000-0000-0000-000000000003&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:10000000-0000-0000-0000-000000000007
-ATTENDEE;CN=User 08;EMAIL=user08@example.com;MEMBER=&quot;urn:x-uid:20000000-0000-0000-0000-000000000002&quot;,&quot;urn:x-uid:20000000-0000-0000-0000-000000000003&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:10000000-0000-0000-0000-000000000008
-ATTENDEE;CN=User 09;EMAIL=user09@example.com;MEMBER=&quot;urn:x-uid:20000000-0000-0000-0000-000000000003&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:10000000-0000-0000-0000-000000000009
</del><ins>+ATTENDEE;CN=User 01;EMAIL=user01@example.com;RSVP=TRUE:urn:x-uid:user01
+ATTENDEE;CN=Group 02;CUTYPE=X-SERVER-GROUP;EMAIL=group02@example.com;RSVP=TRUE:urn:x-uid:group02
+ATTENDEE;CN=Group 03;CUTYPE=X-SERVER-GROUP;EMAIL=group03@example.com;RSVP=TRUE:urn:x-uid:group03
+ATTENDEE;CN=User 06;EMAIL=user06@example.com;MEMBER=&quot;urn:x-uid:group02&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:user06
+ATTENDEE;CN=User 07;EMAIL=user07@example.com;MEMBER=&quot;urn:x-uid:group02&quot;,&quot;urn:x-uid:group03&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:user07
+ATTENDEE;CN=User 08;EMAIL=user08@example.com;MEMBER=&quot;urn:x-uid:group02&quot;,&quot;urn:x-uid:group03&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:user08
+ATTENDEE;CN=User 09;EMAIL=user09@example.com;MEMBER=&quot;urn:x-uid:group03&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:user09
</ins><span class="cx"> CREATED:20060101T150000Z
</span><del>-ORGANIZER;CN=User 01;EMAIL=user01@example.com:urn:x-uid:10000000-0000-0000-0000-000000000001
</del><ins>+ORGANIZER;CN=User 01;EMAIL=user01@example.com:urn:x-uid:user01
</ins><span class="cx"> SUMMARY:event 1
</span><span class="cx"> END:VEVENT
</span><span class="cx"> END:VCALENDAR&quot;&quot;&quot;
</span><span class="lines">@@ -1610,13 +1612,13 @@
</span><span class="cx"> UID:event1@ninevah.local
</span><span class="cx"> DTSTART:20240101T100000Z
</span><span class="cx"> DURATION:PT1H
</span><del>-ATTENDEE;CN=User 01;EMAIL=user01@example.com;RSVP=TRUE:urn:x-uid:10000000-0000-0000-0000-000000000001
-ATTENDEE;CN=Group 02;CUTYPE=X-SERVER-GROUP;EMAIL=group02@example.com;RSVP=TRUE:urn:x-uid:20000000-0000-0000-0000-000000000002
-ATTENDEE;CN=User 06;EMAIL=user06@example.com;MEMBER=&quot;urn:x-uid:20000000-0000-0000-0000-000000000002&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:10000000-0000-0000-0000-000000000006
-ATTENDEE;CN=User 07;EMAIL=user07@example.com;MEMBER=&quot;urn:x-uid:20000000-0000-0000-0000-000000000002&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:10000000-0000-0000-0000-000000000007
-ATTENDEE;CN=User 08;EMAIL=user08@example.com;MEMBER=&quot;urn:x-uid:20000000-0000-0000-0000-000000000002&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:10000000-0000-0000-0000-000000000008
</del><ins>+ATTENDEE;CN=User 01;EMAIL=user01@example.com;RSVP=TRUE:urn:x-uid:user01
+ATTENDEE;CN=Group 02;CUTYPE=X-SERVER-GROUP;EMAIL=group02@example.com;RSVP=TRUE:urn:x-uid:group02
+ATTENDEE;CN=User 06;EMAIL=user06@example.com;MEMBER=&quot;urn:x-uid:group02&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:user06
+ATTENDEE;CN=User 07;EMAIL=user07@example.com;MEMBER=&quot;urn:x-uid:group02&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:user07
+ATTENDEE;CN=User 08;EMAIL=user08@example.com;MEMBER=&quot;urn:x-uid:group02&quot;;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:x-uid:user08
</ins><span class="cx"> CREATED:20060101T150000Z
</span><del>-ORGANIZER;CN=User 01;EMAIL=user01@example.com:urn:x-uid:10000000-0000-0000-0000-000000000001
</del><ins>+ORGANIZER;CN=User 01;EMAIL=user01@example.com:urn:x-uid:user01
</ins><span class="cx"> SEQUENCE:1
</span><span class="cx"> SUMMARY:event 1
</span><span class="cx"> END:VEVENT
</span><span class="lines">@@ -1627,30 +1629,28 @@
</span><span class="cx">         yield calendar.createCalendarObjectWithName(&quot;data1.ics&quot;, vcalendar)
</span><span class="cx">         yield self.commit()
</span><span class="cx"> 
</span><del>-        cobj = yield self.calendarObjectUnderTest(name=&quot;data1.ics&quot;, calendar_name=&quot;calendar&quot;, home=&quot;10000000-0000-0000-0000-000000000001&quot;)
</del><ins>+        cobj = yield self.calendarObjectUnderTest(name=&quot;data1.ics&quot;, calendar_name=&quot;calendar&quot;, home=&quot;user01&quot;)
</ins><span class="cx">         vcalendar = yield cobj.component()
</span><span class="cx">         self._assertICalStrEqual(vcalendar, data_get_1)
</span><span class="cx"> 
</span><del>-        yield self._verifyObjectResourceCount(&quot;10000000-0000-0000-0000-000000000006&quot;, 1)
-        yield self._verifyObjectResourceCount(&quot;10000000-0000-0000-0000-000000000007&quot;, 1)
-        yield self._verifyObjectResourceCount(&quot;10000000-0000-0000-0000-000000000008&quot;, 1)
-        yield self._verifyObjectResourceCount(&quot;10000000-0000-0000-0000-000000000009&quot;, 1)
</del><ins>+        yield self._verifyObjectResourceCount(&quot;user06&quot;, 1)
+        yield self._verifyObjectResourceCount(&quot;user07&quot;, 1)
+        yield self._verifyObjectResourceCount(&quot;user08&quot;, 1)
+        yield self._verifyObjectResourceCount(&quot;user09&quot;, 1)
</ins><span class="cx"> 
</span><span class="cx">         # cache groups
</span><span class="cx">         groupCacher = GroupCacher(self.transactionUnderTest().directoryService())
</span><span class="cx">         groupsToRefresh = yield groupCacher.groupsToRefresh(self.transactionUnderTest())
</span><span class="cx">         self.assertEqual(len(groupsToRefresh), 2)
</span><span class="cx"> 
</span><del>-        wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), &quot;20000000-0000-0000-0000-000000000002&quot;)
</del><ins>+        wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), &quot;group02&quot;)
</ins><span class="cx">         yield self.commit()
</span><del>-        self.assertEqual(len(wps), 1)
-        yield JobItem.waitEmpty(self._sqlCalendarStore.newTransaction, reactor, 60)
-        wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), &quot;20000000-0000-0000-0000-000000000003&quot;)
</del><ins>+        self.assertEqual(len(wps), 0)
+        wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), &quot;group03&quot;)
</ins><span class="cx">         yield self.commit()
</span><del>-        self.assertEqual(len(wps), 1)
-        yield JobItem.waitEmpty(self._sqlCalendarStore.newTransaction, reactor, 60)
</del><ins>+        self.assertEqual(len(wps), 0)
</ins><span class="cx"> 
</span><del>-        cobj = yield self.calendarObjectUnderTest(name=&quot;data1.ics&quot;, calendar_name=&quot;calendar&quot;, home=&quot;10000000-0000-0000-0000-000000000001&quot;)
</del><ins>+        cobj = yield self.calendarObjectUnderTest(name=&quot;data1.ics&quot;, calendar_name=&quot;calendar&quot;, home=&quot;user01&quot;)
</ins><span class="cx">         vcalendar = yield cobj.component()
</span><span class="cx">         self._assertICalStrEqual(vcalendar, data_get_1)
</span><span class="cx"> 
</span><span class="lines">@@ -1658,22 +1658,22 @@
</span><span class="cx">         yield cobj.setComponent(vcalendar)
</span><span class="cx">         yield self.commit()
</span><span class="cx"> 
</span><del>-        cobj = yield self.calendarObjectUnderTest(name=&quot;data1.ics&quot;, calendar_name=&quot;calendar&quot;, home=&quot;10000000-0000-0000-0000-000000000001&quot;)
</del><ins>+        cobj = yield self.calendarObjectUnderTest(name=&quot;data1.ics&quot;, calendar_name=&quot;calendar&quot;, home=&quot;user01&quot;)
</ins><span class="cx">         vcalendar = yield cobj.component()
</span><span class="cx">         self._assertICalStrEqual(vcalendar, data_get_2)
</span><span class="cx"> 
</span><del>-        yield self._verifyObjectResourceCount(&quot;10000000-0000-0000-0000-000000000006&quot;, 1)
-        yield self._verifyObjectResourceCount(&quot;10000000-0000-0000-0000-000000000007&quot;, 1)
-        yield self._verifyObjectResourceCount(&quot;10000000-0000-0000-0000-000000000008&quot;, 1)
-        yield self._verifyObjectResourceCount(&quot;10000000-0000-0000-0000-000000000009&quot;, 1)
</del><ins>+        yield self._verifyObjectResourceCount(&quot;user06&quot;, 1)
+        yield self._verifyObjectResourceCount(&quot;user07&quot;, 1)
+        yield self._verifyObjectResourceCount(&quot;user08&quot;, 1)
+        yield self._verifyObjectResourceCount(&quot;user09&quot;, 1)
</ins><span class="cx"> 
</span><span class="cx">         # groups did not change so no work proposals
</span><del>-        wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), &quot;20000000-0000-0000-0000-000000000002&quot;)
</del><ins>+        wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), &quot;group02&quot;)
</ins><span class="cx">         self.assertEqual(len(wps), 0)
</span><del>-        wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), &quot;20000000-0000-0000-0000-000000000003&quot;)
</del><ins>+        wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), &quot;group03&quot;)
</ins><span class="cx">         self.assertEqual(len(wps), 0)
</span><span class="cx"> 
</span><del>-        cal = yield self.calendarUnderTest(name=&quot;calendar&quot;, home=&quot;10000000-0000-0000-0000-000000000009&quot;)
</del><ins>+        cal = yield self.calendarUnderTest(name=&quot;calendar&quot;, home=&quot;user09&quot;)
</ins><span class="cx">         cobjs = yield cal.objectResources()
</span><span class="cx">         self.assertEqual(len(cobjs), 1)
</span><span class="cx">         comp = yield cobjs[0].componentForUser()
</span></span></pre></div>
<a id="CalendarServertrunktxdavwhotesttest_group_shareespyfromrev13773CalendarServerbranchesusersgayagroupsharee2txdavwhotesttest_group_shareespy"></a>
<div class="copfile"><h4>Copied: CalendarServer/trunk/txdav/who/test/test_group_sharees.py (from rev 13773, CalendarServer/branches/users/gaya/groupsharee2/txdav/who/test/test_group_sharees.py) (0 => 13775)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/who/test/test_group_sharees.py                                (rev 0)
+++ CalendarServer/trunk/txdav/who/test/test_group_sharees.py        2014-07-17 21:54:34 UTC (rev 13775)
</span><span class="lines">@@ -0,0 +1,264 @@
</span><ins>+##
+# Copyright (c) 2014 Apple Inc. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
+# 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 &quot;AS IS&quot; 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.
+##
+
+&quot;&quot;&quot;
+    group sharee tests
+&quot;&quot;&quot;
+
+from twext.enterprise.jobqueue import JobItem
+from twext.python.filepath import CachingFilePath as FilePath
+from twisted.internet import reactor
+from twisted.internet.defer import inlineCallbacks, returnValue
+from twisted.trial import unittest
+from twistedcaldav.config import config
+from txdav.caldav.datastore.test.util import populateCalendarsFrom, CommonCommonTests
+from txdav.who.directory import CalendarDirectoryRecordMixin
+from txdav.who.groups import GroupCacher
+import os
+from txdav.common.datastore.sql_tables import _BIND_MODE_GROUP
+from txdav.common.datastore.sql_tables import _BIND_MODE_READ
+from txdav.common.datastore.sql_tables import _BIND_STATUS_INVITED
+
+
+class GroupShareeTestBase(CommonCommonTests, unittest.TestCase):
+    &quot;&quot;&quot;
+    GroupShareeReconciliation tests
+    &quot;&quot;&quot;
+
+    @inlineCallbacks
+    def setUp(self):
+        yield super(GroupShareeTestBase, self).setUp()
+
+        accountsFilePath = FilePath(
+            os.path.join(os.path.dirname(__file__), &quot;accounts&quot;)
+        )
+        yield self.buildStoreAndDirectory(
+            accounts=accountsFilePath.child(&quot;groupAccounts.xml&quot;),
+        )
+        yield self.populate()
+
+        self.paths = {}
+
+
+    def configure(self):
+        super(GroupShareeTestBase, 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.storeUnderTest())
+
+    requirements = {
+        &quot;user01&quot; : None,
+        &quot;user02&quot; : None,
+        &quot;user06&quot; : None,
+        &quot;user07&quot; : None,
+        &quot;user08&quot; : None,
+        &quot;user09&quot; : None,
+        &quot;user10&quot; : None,
+    }
+
+    @inlineCallbacks
+    def _verifyObjectResourceCount(self, home, expected_count):
+        cal6 = yield self.calendarUnderTest(name=&quot;calendar&quot;, home=home)
+        count = yield cal6.countObjectResources()
+        self.assertEqual(count, expected_count)
+
+
+    @inlineCallbacks
+    def _check_notifications(self, uid, items):
+        notifyHome = yield self.transactionUnderTest().notificationsWithUID(uid)
+        notifications = yield notifyHome.listNotificationObjects()
+        self.assertEqual(set(notifications), set(items))
+
+
+    @inlineCallbacks
+    def shareeViewUnderTest(self, txn=None, shareUID=&quot;calendar_1&quot;, home=&quot;user01&quot;):
+        &quot;&quot;&quot;
+        Get the calendar detailed by C{requirements['home1']['calendar_1']}.
+        &quot;&quot;&quot;
+        returnValue((yield
+            (yield self.homeUnderTest(txn, home)).shareeView(shareUID))
+        )
+
+
+
+class GroupShareeReconciliationTests(GroupShareeTestBase):
+
+    @inlineCallbacks
+    def test_group_change_invite_smaller(self):
+        &quot;&quot;&quot;
+        Test that group shares are changed when the group changes.
+        &quot;&quot;&quot;
+
+        @inlineCallbacks
+        def expandedMembers(self, records=None):
+
+            if self.uid == &quot;group02&quot; or self.uid == &quot;group03&quot;:
+                returnValue(frozenset())
+            else:
+                returnValue((yield unpatchedExpandedMembers(self, records)))
+
+        unpatchedExpandedMembers = CalendarDirectoryRecordMixin.expandedMembers
+
+        # setup group cacher
+        groupCacher = GroupCacher(self.transactionUnderTest().directoryService())
+        groupsToRefresh = yield groupCacher.groupsToRefresh(self.transactionUnderTest())
+        self.assertEqual(len(groupsToRefresh), 0)
+        wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), &quot;group04&quot;)
+        self.assertEqual(len(wps), 0)
+
+        yield self._check_notifications(&quot;user01&quot;, [])
+
+        # Invite
+        calendar = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        invites = yield calendar.sharingInvites()
+        self.assertEqual(len(invites), 0)
+        self.assertFalse(calendar.isShared())
+
+        yield self._check_notifications(&quot;user01&quot;, [])
+        shareeViews = yield calendar.inviteUIDToShare(&quot;group04&quot;, _BIND_MODE_READ)
+        self.assertEqual(len(shareeViews), 5)
+        calendar = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        invites = yield calendar.sharingInvites()
+        self.assertEqual(len(invites), 5)
+        for invite in invites:
+            shareeView = yield calendar.shareeView(invite.shareeUID)
+            self.assertEqual(invite.ownerUID, &quot;user01&quot;)
+            self.assertEqual(invite.uid, shareeView.shareName())
+            self.assertEqual(invite.mode, _BIND_MODE_GROUP)
+            self.assertEqual((yield shareeView.effectiveShareMode()), _BIND_MODE_READ)
+            self.assertEqual(invite.status, _BIND_STATUS_INVITED)
+            self.assertEqual(invite.summary, None)
+            yield self._check_notifications(invite.shareeUID, [invite.uid, ])
+
+        groupsToRefresh = yield groupCacher.groupsToRefresh(self.transactionUnderTest())
+        self.assertEqual(len(groupsToRefresh), 1)
+
+        # 1 group member
+        self.patch(CalendarDirectoryRecordMixin, &quot;expandedMembers&quot;, expandedMembers)
+
+        wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), &quot;group04&quot;)
+        self.assertEqual(len(wps), 1)
+        yield self.commit()
+        yield JobItem.waitEmpty(self._sqlCalendarStore.newTransaction, reactor, 60)
+
+        calendar = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        invites = yield calendar.sharingInvites()
+        self.assertEqual(len(invites), 1)
+        for invite in invites:
+            self.assertEqual(invite.shareeUID, &quot;user10&quot;)
+            shareeView = yield calendar.shareeView(invite.shareeUID)
+            self.assertEqual(invite.ownerUID, &quot;user01&quot;)
+            self.assertEqual(invite.uid, shareeView.shareName())
+            self.assertEqual(invite.mode, _BIND_MODE_GROUP)
+            self.assertEqual((yield shareeView.effectiveShareMode()), _BIND_MODE_READ)
+            self.assertEqual(invite.status, _BIND_STATUS_INVITED)
+            self.assertEqual(invite.summary, None)
+            yield self._check_notifications(invite.shareeUID, [invite.uid, ])
+
+        yield self._check_notifications(&quot;user01&quot;, [])
+
+        # Uninvite
+        calendar = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        yield calendar.uninviteUIDFromShare(&quot;group04&quot;)
+        noinvites = yield calendar.sharingInvites()
+        self.assertEqual(len(noinvites), 0)
+
+
+    @inlineCallbacks
+    def test_group_change_invite_larger(self):
+        &quot;&quot;&quot;
+        Test that group shares are changed when the group changes.
+        &quot;&quot;&quot;
+
+        @inlineCallbacks
+        def expandedMembers(self, records=None):
+
+            if self.uid == &quot;group02&quot; or self.uid == &quot;group03&quot;:
+                returnValue(frozenset())
+            else:
+                returnValue((yield unpatchedExpandedMembers(self, records)))
+
+        unpatchedExpandedMembers = CalendarDirectoryRecordMixin.expandedMembers
+
+        # 1 group member
+        self.patch(CalendarDirectoryRecordMixin, &quot;expandedMembers&quot;, expandedMembers)
+
+        # setup group cacher
+        groupCacher = GroupCacher(self.transactionUnderTest().directoryService())
+        groupsToRefresh = yield groupCacher.groupsToRefresh(self.transactionUnderTest())
+        self.assertEqual(len(groupsToRefresh), 0)
+        wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), &quot;group04&quot;)
+        self.assertEqual(len(wps), 0)
+
+        yield self._check_notifications(&quot;user01&quot;, [])
+
+        # Invite
+        calendar = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        invites = yield calendar.sharingInvites()
+        self.assertEqual(len(invites), 0)
+        self.assertFalse(calendar.isShared())
+
+        yield self._check_notifications(&quot;user01&quot;, [])
+        shareeViews = yield calendar.inviteUIDToShare(&quot;group04&quot;, _BIND_MODE_READ)
+        self.assertEqual(len(shareeViews), 1)
+        invites = yield calendar.sharingInvites()
+        self.assertEqual(len(invites), 1)
+        for invite in invites:
+            self.assertEqual(invite.shareeUID, &quot;user10&quot;)
+            shareeView = yield calendar.shareeView(invite.shareeUID)
+            self.assertEqual(invite.ownerUID, &quot;user01&quot;)
+            self.assertEqual(invite.uid, shareeView.shareName())
+            self.assertEqual(invite.mode, _BIND_MODE_GROUP)
+            self.assertEqual((yield shareeView.effectiveShareMode()), _BIND_MODE_READ)
+            self.assertEqual(invite.status, _BIND_STATUS_INVITED)
+            self.assertEqual(invite.summary, None)
+            yield self._check_notifications(invite.shareeUID, [invite.uid, ])
+
+        groupsToRefresh = yield groupCacher.groupsToRefresh(self.transactionUnderTest())
+        self.assertEqual(len(groupsToRefresh), 1)
+
+        # group members restored
+        self.patch(CalendarDirectoryRecordMixin, &quot;expandedMembers&quot;, unpatchedExpandedMembers)
+
+        wps = yield groupCacher.refreshGroup(self.transactionUnderTest(), &quot;group04&quot;)
+        self.assertEqual(len(wps), 1)
+        yield self.commit()
+        yield JobItem.waitEmpty(self._sqlCalendarStore.newTransaction, reactor, 60)
+
+        calendar = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        invites = yield calendar.sharingInvites()
+        self.assertEqual(len(invites), 5)
+        for invite in invites:
+            shareeView = yield calendar.shareeView(invite.shareeUID)
+            self.assertEqual(invite.ownerUID, &quot;user01&quot;)
+            self.assertEqual(invite.uid, shareeView.shareName())
+            self.assertEqual(invite.mode, _BIND_MODE_GROUP)
+            self.assertEqual((yield shareeView.effectiveShareMode()), _BIND_MODE_READ)
+            self.assertEqual(invite.status, _BIND_STATUS_INVITED)
+            self.assertEqual(invite.summary, None)
+            yield self._check_notifications(invite.shareeUID, [invite.uid, ])
+
+        # Uninvite
+        calendar = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        yield calendar.uninviteUIDFromShare(&quot;group04&quot;)
+        noinvites = yield calendar.sharingInvites()
+        self.assertEqual(len(noinvites), 0)
</ins></span></pre></div>
<a id="CalendarServertrunktxdavwhotesttest_groupspy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/who/test/test_groups.py (13774 => 13775)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/who/test/test_groups.py        2014-07-17 19:55:36 UTC (rev 13774)
+++ CalendarServer/trunk/txdav/who/test/test_groups.py        2014-07-17 21:54:34 UTC (rev 13775)
</span><span class="lines">@@ -78,7 +78,7 @@
</span><span class="cx">         self.assertEquals(membershipHash, &quot;553eb54e3bbb26582198ee04541dbee4&quot;)
</span><span class="cx">         self.assertEquals(extant, True)
</span><span class="cx"> 
</span><del>-        members = (yield txn.membersOfGroup(groupID))
</del><ins>+        members = (yield txn.groupMemberUIDs(groupID))
</ins><span class="cx">         self.assertEquals(
</span><span class="cx">             set([u'__cdaboo1__', u'__glyph1__', u'__sagen1__', u'__wsanchez1__']),
</span><span class="cx">             members
</span><span class="lines">@@ -510,7 +510,7 @@
</span><span class="cx"> 
</span><span class="cx">         # The list of members stored in the DB for this group is now empty
</span><span class="cx">         txn = store.newTransaction()
</span><del>-        members = yield txn.membersOfGroup(groupID)
</del><ins>+        members = yield txn.groupMemberUIDs(groupID)
</ins><span class="cx">         yield txn.commit()
</span><span class="cx">         self.assertEquals(members, set())
</span><span class="cx"> 
</span><span class="lines">@@ -545,6 +545,6 @@
</span><span class="cx"> 
</span><span class="cx">         # The list of members stored in the DB for this group has 100 users
</span><span class="cx">         txn = store.newTransaction()
</span><del>-        members = yield txn.membersOfGroup(groupID)
</del><ins>+        members = yield txn.groupMemberUIDs(groupID)
</ins><span class="cx">         yield txn.commit()
</span><span class="cx">         self.assertEquals(len(members), 100)
</span></span></pre>
</div>
</div>

</body>
</html>