<!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>[11945] CalendarServer/branches/users/cdaboo/sharing-in-the-store</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/11945">11945</a></dd>
<dt>Author</dt> <dd>cdaboo@apple.com</dd>
<dt>Date</dt> <dd>2013-11-13 19:47:16 -0800 (Wed, 13 Nov 2013)</dd>
</dl>

<h3>Log Message</h3>
<pre>Switch notifications to be stored as JSON in the DB but re-written to XML in the app.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#CalendarServerbranchesuserscdaboosharinginthestorecalendarservertapcaldavpy">CalendarServer/branches/users/cdaboo/sharing-in-the-store/calendarserver/tap/caldav.py</a></li>
<li><a href="#CalendarServerbranchesuserscdaboosharinginthestoretwistedcaldavcustomxmlpy">CalendarServer/branches/users/cdaboo/sharing-in-the-store/twistedcaldav/customxml.py</a></li>
<li><a href="#CalendarServerbranchesuserscdaboosharinginthestoretwistedcaldavsharingpy">CalendarServer/branches/users/cdaboo/sharing-in-the-store/twistedcaldav/sharing.py</a></li>
<li><a href="#CalendarServerbranchesuserscdaboosharinginthestoretwistedcaldavstorebridgepy">CalendarServer/branches/users/cdaboo/sharing-in-the-store/twistedcaldav/storebridge.py</a></li>
<li><a href="#CalendarServerbranchesuserscdaboosharinginthestoretxdavcaldavdatastoretestcommonpy">CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/caldav/datastore/test/common.py</a></li>
<li><a href="#CalendarServerbranchesuserscdaboosharinginthestoretxdavcommondatastorefilepy">CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/file.py</a></li>
<li><a href="#CalendarServerbranchesuserscdaboosharinginthestoretxdavcommondatastoresqlpy">CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/sql.py</a></li>
<li><a href="#CalendarServerbranchesuserscdaboosharinginthestoretxdavcommondatastoresql_schemacurrentoracledialectsql">CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/sql_schema/current-oracle-dialect.sql</a></li>
<li><a href="#CalendarServerbranchesuserscdaboosharinginthestoretxdavcommondatastoresql_schemacurrentsql">CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/sql_schema/current.sql</a></li>
<li><a href="#CalendarServerbranchesuserscdaboosharinginthestoretxdavcommondatastoretestutilpy">CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/test/util.py</a></li>
<li><a href="#CalendarServerbranchesuserscdaboosharinginthestoretxdavcommondatastoreupgradesqlupgradepy">CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/upgrade/sql/upgrade.py</a></li>
<li><a href="#CalendarServerbranchesuserscdaboosharinginthestoretxdavcommondatastoreupgradesqlupgradesutilpy">CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/upgrade/sql/upgrades/util.py</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#CalendarServerbranchesuserscdaboosharinginthestoretxdavcommondatastoresql_schemaoldoracledialectv28sql">CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/sql_schema/old/oracle-dialect/v28.sql</a></li>
<li><a href="#CalendarServerbranchesuserscdaboosharinginthestoretxdavcommondatastoresql_schemaoldpostgresdialectv28sql">CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/sql_schema/old/postgres-dialect/v28.sql</a></li>
<li><a href="#CalendarServerbranchesuserscdaboosharinginthestoretxdavcommondatastoresql_schemaupgradesoracledialectupgrade_from_28_to_29sql">CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_28_to_29.sql</a></li>
<li><a href="#CalendarServerbranchesuserscdaboosharinginthestoretxdavcommondatastoresql_schemaupgradespostgresdialectupgrade_from_28_to_29sql">CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/sql_schema/upgrades/postgres-dialect/upgrade_from_28_to_29.sql</a></li>
<li><a href="#CalendarServerbranchesuserscdaboosharinginthestoretxdavcommondatastoreupgradesqlupgradesnotification_upgrade_from_0_to_1py">CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/upgrade/sql/upgrades/notification_upgrade_from_0_to_1.py</a></li>
<li><a href="#CalendarServerbranchesuserscdaboosharinginthestoretxdavcommondatastoreupgradesqlupgradestesttest_notification_upgrade_from_0_to_1py">CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/upgrade/sql/upgrades/test/test_notification_upgrade_from_0_to_1.py</a></li>
</ul>

<h3>Property Changed</h3>
<ul>
<li><a href="#CalendarServerbranchesuserscdaboosharinginthestore">CalendarServer/branches/users/cdaboo/sharing-in-the-store/</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalendarServerbranchesuserscdaboosharinginthestore"></a>
<div class="propset"><h4>Property changes: CalendarServer/branches/users/cdaboo/sharing-in-the-store</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/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/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/shared-calendars-5187:5188-5440
</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/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/purge_old_events:6735-6746
</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/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/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/shared-calendars-5187:5188-5440
</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/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/purge_old_events:6735-6746
</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">/CalendarServer/trunk:11935-11938
</span><a id="CalendarServerbranchesuserscdaboosharinginthestorecalendarservertapcaldavpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/sharing-in-the-store/calendarserver/tap/caldav.py (11944 => 11945)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/sharing-in-the-store/calendarserver/tap/caldav.py        2013-11-14 03:37:20 UTC (rev 11944)
+++ CalendarServer/branches/users/cdaboo/sharing-in-the-store/calendarserver/tap/caldav.py        2013-11-14 03:47:16 UTC (rev 11945)
</span><span class="lines">@@ -72,8 +72,7 @@
</span><span class="cx"> from txdav.common.datastore.upgrade.sql.upgrade import (
</span><span class="cx">     UpgradeDatabaseSchemaStep, UpgradeDatabaseAddressBookDataStep,
</span><span class="cx">     UpgradeDatabaseCalendarDataStep, UpgradeDatabaseOtherStep,
</span><del>-    UpgradeAcquireLockStep, UpgradeReleaseLockStep
-)
</del><ins>+    UpgradeAcquireLockStep, UpgradeReleaseLockStep, UpgradeDatabaseNotificationDataStep)
</ins><span class="cx"> from txdav.common.datastore.upgrade.migrate import UpgradeToDatabaseStep
</span><span class="cx"> from txdav.caldav.datastore.scheduling.imip.inbound import MailRetriever
</span><span class="cx"> from txdav.caldav.datastore.scheduling.imip.inbound import scheduleNextMailPoll
</span><span class="lines">@@ -1420,6 +1419,12 @@
</span><span class="cx">                 )
</span><span class="cx"> 
</span><span class="cx">                 pps.addStep(
</span><ins>+                    UpgradeDatabaseNotificationDataStep(
+                        store, uid=overrideUID, gid=overrideGID
+                    )
+                )
+
+                pps.addStep(
</ins><span class="cx">                     UpgradeToDatabaseStep(
</span><span class="cx">                         UpgradeToDatabaseStep.fileStoreFromPath(
</span><span class="cx">                             CachingFilePath(config.DocumentRoot)
</span></span></pre></div>
<a id="CalendarServerbranchesuserscdaboosharinginthestoretwistedcaldavcustomxmlpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/sharing-in-the-store/twistedcaldav/customxml.py (11944 => 11945)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/sharing-in-the-store/twistedcaldav/customxml.py        2013-11-14 03:37:20 UTC (rev 11944)
+++ CalendarServer/branches/users/cdaboo/sharing-in-the-store/twistedcaldav/customxml.py        2013-11-14 03:47:16 UTC (rev 11945)
</span><span class="lines">@@ -639,8 +639,9 @@
</span><span class="cx">     name = &quot;dtstamp&quot;
</span><span class="cx"> 
</span><span class="cx">     def __init__(self, *children):
</span><del>-        super(DTStamp, self).__init__(children)
-        self.children = (PCDATAElement(DateTime.getNowUTC().getText()),)
</del><ins>+        super(DTStamp, self).__init__(*children)
+        if not self.children:
+            self.children = (PCDATAElement(DateTime.getNowUTC().getText()),)
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> 
</span></span></pre></div>
<a id="CalendarServerbranchesuserscdaboosharinginthestoretwistedcaldavsharingpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/sharing-in-the-store/twistedcaldav/sharing.py (11944 => 11945)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/sharing-in-the-store/twistedcaldav/sharing.py        2013-11-14 03:37:20 UTC (rev 11944)
+++ CalendarServer/branches/users/cdaboo/sharing-in-the-store/twistedcaldav/sharing.py        2013-11-14 03:47:16 UTC (rev 11945)
</span><span class="lines">@@ -48,7 +48,9 @@
</span><span class="cx"> 
</span><span class="cx"> from pycalendar.datetime import DateTime
</span><span class="cx"> 
</span><ins>+import json
</ins><span class="cx"> 
</span><ins>+
</ins><span class="cx"> # FIXME: Get rid of these imports
</span><span class="cx"> from twistedcaldav.directory.util import TRANSACTION_KEY
</span><span class="cx"> # circular import
</span><span class="lines">@@ -706,19 +708,16 @@
</span><span class="cx">     def sendInviteNotification(self, invitation, request, notificationState=None, displayName=None):
</span><span class="cx"> 
</span><span class="cx">         ownerPrincipal = (yield self.ownerPrincipal(request))
</span><del>-        # FIXME:  use urn:uuid in all cases
-        if self.isCalendarCollection():
-            owner = ownerPrincipal.principalURL()
-        else:
-            owner = &quot;urn:uuid:&quot; + ownerPrincipal.principalUID()
-        ownerCN = ownerPrincipal.displayName()
-        hosturl = (yield self.canonicalURL(request))
</del><span class="cx"> 
</span><span class="cx">         # Locate notifications collection for user
</span><span class="cx">         sharee = self.principalForUID(invitation.shareeUID())
</span><span class="cx">         if sharee is None:
</span><span class="cx">             raise ValueError(&quot;sharee is None but principalUID was valid before&quot;)
</span><span class="cx"> 
</span><ins>+        hosturl = self._newStoreObject.name()
+        if self.sharedResourceType() == &quot;group&quot;:
+            hosturl = self._newStoreObject.parentCollection().name() + &quot;/&quot; + hosturl
+
</ins><span class="cx">         # We need to look up the resource so that the response cache notifier is properly initialized
</span><span class="cx">         notificationResource = (yield request.locateResource(sharee.notificationURL()))
</span><span class="cx">         notifications = notificationResource._newStoreNotifications
</span><span class="lines">@@ -733,32 +732,31 @@
</span><span class="cx">         '''
</span><span class="cx"> 
</span><span class="cx">         # Generate invite XML
</span><del>-        userid = &quot;urn:uuid:&quot; + invitation.shareeUID()
</del><span class="cx">         state = notificationState if notificationState else invitation.status()
</span><span class="cx">         summary = invitation.summary() if displayName is None else displayName
</span><span class="cx"> 
</span><del>-        typeAttr = {'shared-type': self.sharedResourceType()}
-        xmltype = customxml.InviteNotification(**typeAttr)
-        xmldata = customxml.Notification(
-            customxml.DTStamp.fromString(DateTime.getNowUTC().getText()),
-            customxml.InviteNotification(
-                customxml.UID.fromString(invitation.uid()),
-                element.HRef.fromString(userid),
-                invitationBindStatusToXMLMap[state](),
-                customxml.InviteAccess(invitationBindModeToXMLMap[invitation.mode()]()),
-                customxml.HostURL(
-                    element.HRef.fromString(hosturl),
-                ),
-                customxml.Organizer(
-                    element.HRef.fromString(owner),
-                    customxml.CommonName.fromString(ownerCN),
-                ),
-                customxml.InviteSummary.fromString(summary),
-                self.getSupportedComponentSet() if self.isCalendarCollection() else None,
-                **typeAttr
-            ),
-        ).toxml()
</del><ins>+        xmltype = {
+            &quot;notification-type&quot;: &quot;invite-notification&quot;,
+            &quot;shared-type&quot;: self.sharedResourceType(),
+        }
+        xmldata = {
+            &quot;notification-type&quot;: &quot;invite-notification&quot;,
+            &quot;shared-type&quot;: self.sharedResourceType(),
+            &quot;dtstamp&quot;: DateTime.getNowUTC().getText(),
+            &quot;owner&quot;: ownerPrincipal.principalUID(),
+            &quot;sharee&quot;: invitation.shareeUID(),
+            &quot;uid&quot;: invitation.uid(),
+            &quot;status&quot;: state,
+            &quot;access&quot;: invitation.mode(),
+            &quot;name&quot;: hosturl,
+            &quot;summary&quot;: summary,
+        }
+        if self.isCalendarCollection():
+            xmldata[&quot;supported-components&quot;] = self._newStoreObject.getSupportedComponents()
</ins><span class="cx"> 
</span><ins>+        xmltype = json.dumps(xmltype)
+        xmldata = json.dumps(xmldata)
+
</ins><span class="cx">         # Add to collections
</span><span class="cx">         yield notifications.writeNotificationObject(invitation.uid(), xmltype, xmldata)
</span><span class="cx"> 
</span><span class="lines">@@ -1333,52 +1331,41 @@
</span><span class="cx">     def sendReply(self, request, shareePrincipal, sharedResource, state, hostUrl, replytoUID, displayname=None):
</span><span class="cx"> 
</span><span class="cx">         # Locate notifications collection for owner
</span><del>-        owner = (yield sharedResource.ownerPrincipal(request))
-        if owner is None:
</del><ins>+        ownerPrincipal = (yield sharedResource.ownerPrincipal(request))
+        if ownerPrincipal is None:
</ins><span class="cx">             # FIXME: have to return here rather than raise to allow removal of a share for a sharer
</span><span class="cx">             # whose principal is no longer valid yet still exists in the store. Really we need to get rid of
</span><span class="cx">             # locateResource calls and just do everything via store objects.
</span><span class="cx">             returnValue(None)
</span><span class="cx"> 
</span><del>-        notificationResource = (yield request.locateResource(owner.notificationURL()))
</del><ins>+        hosturl = sharedResource._newStoreObject.name()
+        if sharedResource.sharedResourceType() == &quot;group&quot;:
+            hosturl = sharedResource._newStoreObject.parentCollection().name() + &quot;/&quot; + hosturl
+
+        notificationResource = (yield request.locateResource(ownerPrincipal.notificationURL()))
</ins><span class="cx">         notifications = notificationResource._newStoreNotifications
</span><span class="cx"> 
</span><span class="cx">         # Generate invite XML
</span><span class="cx">         notificationUID = &quot;%s-reply&quot; % (replytoUID,)
</span><del>-        xmltype = customxml.InviteReply()
</del><span class="cx"> 
</span><del>-        # FIXME:  use urn:uuid in all cases
-        if self._newStoreHome and self._newStoreHome._homeType == EADDRESSBOOKTYPE:
-            cua = &quot;urn:uuid:&quot; + shareePrincipal.principalUID()
-        else:
-            # Prefer mailto:, otherwise use principal URL
-            for cua in shareePrincipal.calendarUserAddresses():
-                if cua.startswith(&quot;mailto:&quot;):
-                    break
-            else:
-                cua = shareePrincipal.principalURL()
</del><ins>+        xmltype = {
+            &quot;notification-type&quot;: &quot;invite-reply&quot;,
+        }
</ins><span class="cx"> 
</span><del>-        commonName = shareePrincipal.displayName()
-        record = shareePrincipal.record
</del><ins>+        xmldata = {
+            &quot;notification-type&quot;: &quot;invite-reply&quot;,
+            &quot;shared-type&quot;: sharedResource.sharedResourceType(),
+            &quot;dtstamp&quot;: DateTime.getNowUTC().getText(),
+            &quot;owner&quot;: ownerPrincipal.principalUID(),
+            &quot;sharee&quot;: shareePrincipal.principalUID(),
+            &quot;status&quot;: state,
+            &quot;name&quot;: hosturl,
+            &quot;in-reply-to&quot;: replytoUID,
+            &quot;summary&quot;: displayname if displayname is not None else &quot;&quot;,
+        }
</ins><span class="cx"> 
</span><del>-        xmldata = customxml.Notification(
-            customxml.DTStamp.fromString(DateTime.getNowUTC().getText()),
-            customxml.InviteReply(
-                *(
-                    (
-                        element.HRef.fromString(cua),
-                        invitationBindStatusToXMLMap[state](),
-                        customxml.HostURL(
-                            element.HRef.fromString(hostUrl),
-                        ),
-                        customxml.InReplyTo.fromString(replytoUID),
-                    ) + ((customxml.InviteSummary.fromString(displayname),) if displayname is not None else ())
-                      + ((customxml.CommonName.fromString(commonName),) if commonName is not None else ())
-                      + ((customxml.FirstNameProperty(record.firstName),) if record.firstName is not None else ())
-                      + ((customxml.LastNameProperty(record.lastName),) if record.lastName is not None else ())
-                )
-            ),
-        ).toxml()
</del><ins>+        xmltype = json.dumps(xmltype)
+        xmldata = json.dumps(xmldata)
</ins><span class="cx"> 
</span><span class="cx">         # Add to collections
</span><span class="cx">         yield notifications.writeNotificationObject(notificationUID, xmltype, xmldata)
</span></span></pre></div>
<a id="CalendarServerbranchesuserscdaboosharinginthestoretwistedcaldavstorebridgepy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/sharing-in-the-store/twistedcaldav/storebridge.py (11944 => 11945)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/sharing-in-the-store/twistedcaldav/storebridge.py        2013-11-14 03:37:20 UTC (rev 11944)
+++ CalendarServer/branches/users/cdaboo/sharing-in-the-store/twistedcaldav/storebridge.py        2013-11-14 03:47:16 UTC (rev 11945)
</span><span class="lines">@@ -70,10 +70,10 @@
</span><span class="cx">     UIDExistsElsewhereError, InvalidUIDError, InvalidResourceMove, \
</span><span class="cx">     InvalidComponentForStoreError
</span><span class="cx"> from txdav.idav import PropertyChangeNotAllowedError
</span><del>-from txdav.xml import element as davxml
</del><ins>+from txdav.xml import element as davxml, element
</ins><span class="cx"> from txdav.xml.base import dav_namespace, WebDAVUnknownElement, encodeXMLName
</span><span class="cx"> 
</span><del>-from urlparse import urlsplit
</del><ins>+from urlparse import urlsplit, urljoin
</ins><span class="cx"> import hashlib
</span><span class="cx"> import time
</span><span class="cx"> import uuid
</span><span class="lines">@@ -84,6 +84,9 @@
</span><span class="cx">     TooManyInstancesError
</span><span class="cx"> from twistedcaldav.util import bestAcceptType
</span><span class="cx"> import collections
</span><ins>+from twistedcaldav.sharing import invitationBindStatusToXMLMap, \
+    invitationBindModeToXMLMap
+import json
</ins><span class="cx"> 
</span><span class="cx"> &quot;&quot;&quot;
</span><span class="cx"> Wrappers to translate between the APIs in L{txdav.caldav.icalendarstore} and
</span><span class="lines">@@ -3717,7 +3720,16 @@
</span><span class="cx">             qname = prop.qname()
</span><span class="cx"> 
</span><span class="cx">         if qname == customxml.NotificationType.qname():
</span><del>-            returnValue(self._newStoreObject.xmlType())
</del><ins>+            jsontype = self._newStoreObject.xmlType()
+            jsontype = json.loads(jsontype)
+            if jsontype[&quot;notification-type&quot;] == &quot;invite-notification&quot;:
+                typeAttr = {&quot;shared-type&quot;: jsontype[&quot;shared-type&quot;]}
+                xmltype = customxml.InviteNotification(**typeAttr)
+            elif jsontype[&quot;notification-type&quot;] == &quot;invite-reply&quot;:
+                xmltype = customxml.InviteReply()
+            else:
+                raise HTTPError(responsecode.INTERNAL_SERVER_ERROR)
+            returnValue(customxml.NotificationType(xmltype))
</ins><span class="cx"> 
</span><span class="cx">         returnValue((yield super(StoreNotificationObjectFile, self).readProperty(prop, request)))
</span><span class="cx"> 
</span><span class="lines">@@ -3730,11 +3742,99 @@
</span><span class="cx">         return succeed(self._newStoreObject.size())
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+    @inlineCallbacks
</ins><span class="cx">     def text(self, ignored=None):
</span><span class="cx">         assert ignored is None, &quot;This is a notification object, not a notification&quot;
</span><del>-        return self._newStoreObject.xmldata()
</del><ins>+        jsondata = (yield self._newStoreObject.xmldata())
+        jsondata = json.loads(jsondata)
+        if jsondata[&quot;notification-type&quot;] == &quot;invite-notification&quot;:
+            ownerPrincipal = self.principalForUID(jsondata[&quot;owner&quot;])
+            ownerCN = ownerPrincipal.displayName()
+            ownerHomeURL = ownerPrincipal.calendarHomeURLs()[0] if jsondata[&quot;shared-type&quot;] == &quot;calendar&quot; else ownerPrincipal.addressBookHomeURLs()[0]
</ins><span class="cx"> 
</span><ins>+            # FIXME:  use urn:uuid always?
+            if jsondata[&quot;shared-type&quot;] == &quot;calendar&quot;:
+                owner = ownerPrincipal.principalURL()
+            else:
+                owner = &quot;urn:uuid:&quot; + ownerPrincipal.principalUID()
</ins><span class="cx"> 
</span><ins>+            shareePrincipal = self.principalForUID(jsondata[&quot;sharee&quot;])
+
+            if &quot;supported-components&quot; in jsondata:
+                comps = jsondata[&quot;supported-components&quot;]
+                if comps:
+                    comps = comps.split(&quot;,&quot;)
+                else:
+                    comps = ical.allowedStoreComponents
+                supported = caldavxml.SupportedCalendarComponentSet(
+                    *[caldavxml.CalendarComponent(name=item) for item in comps]
+                )
+            else:
+                supported = None
+
+            typeAttr = {&quot;shared-type&quot;: jsondata[&quot;shared-type&quot;]}
+            xmldata = customxml.Notification(
+                customxml.DTStamp.fromString(jsondata[&quot;dtstamp&quot;]),
+                customxml.InviteNotification(
+                    customxml.UID.fromString(jsondata[&quot;uid&quot;]),
+                    element.HRef.fromString(&quot;urn:uuid:&quot; + jsondata[&quot;sharee&quot;]),
+                    invitationBindStatusToXMLMap[jsondata[&quot;status&quot;]](),
+                    customxml.InviteAccess(invitationBindModeToXMLMap[jsondata[&quot;access&quot;]]()),
+                    customxml.HostURL(
+                        element.HRef.fromString(urljoin(ownerHomeURL, jsondata[&quot;name&quot;])),
+                    ),
+                    customxml.Organizer(
+                        element.HRef.fromString(owner),
+                        customxml.CommonName.fromString(ownerCN),
+                    ),
+                    customxml.InviteSummary.fromString(jsondata[&quot;summary&quot;]),
+                    supported,
+                    **typeAttr
+                ),
+            )
+        elif jsondata[&quot;notification-type&quot;] == &quot;invite-reply&quot;:
+            ownerPrincipal = self.principalForUID(jsondata[&quot;owner&quot;])
+            ownerHomeURL = ownerPrincipal.calendarHomeURLs()[0] if jsondata[&quot;shared-type&quot;] == &quot;calendar&quot; else ownerPrincipal.addressBookHomeURLs()[0]
+
+            shareePrincipal = self.principalForUID(jsondata[&quot;sharee&quot;])
+
+            # FIXME:  use urn:uuid always?
+            if jsondata[&quot;shared-type&quot;] == &quot;calendar&quot;:
+                # Prefer mailto:, otherwise use principal URL
+                for cua in shareePrincipal.calendarUserAddresses():
+                    if cua.startswith(&quot;mailto:&quot;):
+                        break
+                else:
+                    cua = shareePrincipal.principalURL()
+            else:
+                cua = &quot;urn:uuid:&quot; + shareePrincipal.principalUID()
+
+            commonName = shareePrincipal.displayName()
+            record = shareePrincipal.record
+
+            xmldata = customxml.Notification(
+                customxml.DTStamp.fromString(jsondata[&quot;dtstamp&quot;]),
+                customxml.InviteReply(
+                    *(
+                        (
+                            element.HRef.fromString(cua),
+                            invitationBindStatusToXMLMap[jsondata[&quot;status&quot;]](),
+                            customxml.HostURL(
+                                element.HRef.fromString(urljoin(ownerHomeURL, jsondata[&quot;name&quot;])),
+                            ),
+                            customxml.InReplyTo.fromString(jsondata[&quot;in-reply-to&quot;]),
+                        ) + ((customxml.InviteSummary.fromString(jsondata[&quot;summary&quot;]),) if jsondata[&quot;summary&quot;] else ())
+                          + ((customxml.CommonName.fromString(commonName),) if commonName else ())
+                          + ((customxml.FirstNameProperty(record.firstName),) if record.firstName else ())
+                          + ((customxml.LastNameProperty(record.lastName),) if record.lastName else ())
+                    )
+                ),
+            )
+        else:
+            raise HTTPError(responsecode.INTERNAL_SERVER_ERROR)
+        returnValue(xmldata.toxml())
+
+
</ins><span class="cx">     @requiresPermissions(davxml.Read())
</span><span class="cx">     @inlineCallbacks
</span><span class="cx">     def http_GET(self, request):
</span></span></pre></div>
<a id="CalendarServerbranchesuserscdaboosharinginthestoretxdavcaldavdatastoretestcommonpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/caldav/datastore/test/common.py (11944 => 11945)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/caldav/datastore/test/common.py        2013-11-14 03:37:20 UTC (rev 11944)
+++ CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/caldav/datastore/test/common.py        2013-11-14 03:47:16 UTC (rev 11945)
</span><span class="lines">@@ -48,14 +48,15 @@
</span><span class="cx">     ICalendar, ICalendarTransaction,
</span><span class="cx">     ComponentUpdateState)
</span><span class="cx"> 
</span><del>-from twistedcaldav.customxml import InviteNotification, InviteSummary
</del><span class="cx"> from txdav.common.datastore.test.util import transactionClean
</span><span class="cx"> from txdav.common.icommondatastore import ConcurrentModification
</span><span class="cx"> from twistedcaldav.ical import Component
</span><span class="cx"> from twistedcaldav.config import config
</span><span class="cx"> from calendarserver.push.util import PushPriority
</span><span class="cx"> 
</span><ins>+import json
</ins><span class="cx"> 
</span><ins>+
</ins><span class="cx"> storePath = FilePath(__file__).parent().child(&quot;calendar_store&quot;)
</span><span class="cx"> 
</span><span class="cx"> homeRoot = storePath.child(&quot;ho&quot;).child(&quot;me&quot;).child(&quot;home1&quot;)
</span><span class="lines">@@ -374,9 +375,11 @@
</span><span class="cx">     def notificationUnderTest(self):
</span><span class="cx">         txn = self.transactionUnderTest()
</span><span class="cx">         notifications = yield txn.notificationsWithUID(&quot;home1&quot;)
</span><del>-        inviteNotification = InviteNotification()
-        yield notifications.writeNotificationObject(&quot;abc&quot;, inviteNotification,
-            inviteNotification.toxml())
</del><ins>+        yield notifications.writeNotificationObject(
+            &quot;abc&quot;,
+            &quot;{\&quot;notification-type\&quot;:\&quot;invite-notification\&quot;}&quot;,
+            &quot;{\&quot;notification-type\&quot;:\&quot;invite-notification\&quot;}&quot;
+        )
</ins><span class="cx">         notificationObject = yield notifications.notificationObjectWithUID(&quot;abc&quot;)
</span><span class="cx">         returnValue(notificationObject)
</span><span class="cx"> 
</span><span class="lines">@@ -399,10 +402,9 @@
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         txn = self.transactionUnderTest()
</span><span class="cx">         coll = yield txn.notificationsWithUID(&quot;home1&quot;)
</span><del>-        invite1 = InviteNotification()
-        yield coll.writeNotificationObject(&quot;1&quot;, invite1, invite1.toxml())
</del><ins>+        yield coll.writeNotificationObject(&quot;1&quot;, &quot;{\&quot;notification-type\&quot;:\&quot;invite-notification\&quot;}&quot;, &quot;{\&quot;notification-type\&quot;:\&quot;invite-notification\&quot;}&quot;)
</ins><span class="cx">         st = yield coll.syncToken()
</span><del>-        yield coll.writeNotificationObject(&quot;2&quot;, invite1, invite1.toxml())
</del><ins>+        yield coll.writeNotificationObject(&quot;2&quot;, &quot;{\&quot;notification-type\&quot;:\&quot;invite-notification\&quot;}&quot;, &quot;{\&quot;notification-type\&quot;:\&quot;invite-notification\&quot;}&quot;)
</ins><span class="cx">         rev = self.token2revision(st)
</span><span class="cx">         yield coll.removeNotificationObjectWithUID(&quot;1&quot;)
</span><span class="cx">         st2 = yield coll.syncToken()
</span><span class="lines">@@ -424,14 +426,21 @@
</span><span class="cx">         notifications = yield self.transactionUnderTest().notificationsWithUID(
</span><span class="cx">             &quot;home1&quot;
</span><span class="cx">         )
</span><del>-        inviteNotification = InviteNotification()
-        yield notifications.writeNotificationObject(&quot;abc&quot;, inviteNotification,
-            inviteNotification.toxml())
-        inviteNotification2 = InviteNotification(InviteSummary(&quot;a summary&quot;))
</del><span class="cx">         yield notifications.writeNotificationObject(
</span><del>-            &quot;abc&quot;, inviteNotification, inviteNotification2.toxml())
</del><ins>+            &quot;abc&quot;,
+            &quot;{\&quot;notification-type\&quot;:\&quot;invite-notification\&quot;}&quot;,
+            &quot;{\&quot;notification-type\&quot;:\&quot;invite-notification\&quot;}&quot;,
+        )
+        yield notifications.writeNotificationObject(
+            &quot;abc&quot;,
+            &quot;{\&quot;notification-type\&quot;:\&quot;invite-notification\&quot;}&quot;,
+            &quot;{\&quot;notification-type\&quot;:\&quot;invite-notification\&quot;,\&quot;summary\&quot;:\&quot;a summary\&quot;}&quot;,
+        )
</ins><span class="cx">         abc = yield notifications.notificationObjectWithUID(&quot;abc&quot;)
</span><del>-        self.assertEquals((yield abc.xmldata()), inviteNotification2.toxml())
</del><ins>+        self.assertEquals(
+            json.loads((yield abc.xmldata())),
+            json.loads(&quot;{\&quot;notification-type\&quot;:\&quot;invite-notification\&quot;,\&quot;summary\&quot;:\&quot;a summary\&quot;}&quot;),
+        )
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><span class="lines">@@ -450,9 +459,11 @@
</span><span class="cx">             &quot;home1&quot;
</span><span class="cx">         )
</span><span class="cx">         self.notifierFactory.reset()
</span><del>-        inviteNotification = InviteNotification()
-        yield notifications.writeNotificationObject(&quot;abc&quot;, inviteNotification,
-            inviteNotification.toxml())
</del><ins>+        yield notifications.writeNotificationObject(
+            &quot;abc&quot;,
+            &quot;{\&quot;notification-type\&quot;:\&quot;invite-notification\&quot;}&quot;,
+            &quot;{\&quot;notification-type\&quot;:\&quot;invite-notification\&quot;}&quot;,
+        )
</ins><span class="cx"> 
</span><span class="cx">         # notify is called prior to commit
</span><span class="cx">         self.assertEquals(
</span><span class="lines">@@ -492,12 +503,16 @@
</span><span class="cx">         notifications = yield self.transactionUnderTest().notificationsWithUID(
</span><span class="cx">             &quot;home1&quot;
</span><span class="cx">         )
</span><del>-        inviteNotification = InviteNotification()
-        yield notifications.writeNotificationObject(&quot;abc&quot;, inviteNotification,
-            inviteNotification.toxml())
-        inviteNotification2 = InviteNotification(InviteSummary(&quot;a summary&quot;))
</del><span class="cx">         yield notifications.writeNotificationObject(
</span><del>-            &quot;def&quot;, inviteNotification, inviteNotification2.toxml())
</del><ins>+            &quot;abc&quot;,
+            &quot;{\&quot;notification-type\&quot;:\&quot;invite-notification\&quot;}&quot;,
+            &quot;{\&quot;notification-type\&quot;:\&quot;invite-notification\&quot;}&quot;,
+        )
+        yield notifications.writeNotificationObject(
+            &quot;def&quot;,
+            &quot;{\&quot;notification-type\&quot;:\&quot;invite-notification\&quot;}&quot;,
+            &quot;{\&quot;notification-type\&quot;:\&quot;invite-notification\&quot;,\&quot;summary\&quot;:\&quot;a summary\&quot;}&quot;,
+        )
</ins><span class="cx"> 
</span><span class="cx">         yield self.commit()
</span><span class="cx"> 
</span></span></pre></div>
<a id="CalendarServerbranchesuserscdaboosharinginthestoretxdavcommondatastorefilepy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/file.py (11944 => 11945)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/file.py        2013-11-14 03:37:20 UTC (rev 11944)
+++ CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/file.py        2013-11-14 03:47:16 UTC (rev 11945)
</span><span class="lines">@@ -1509,7 +1509,7 @@
</span><span class="cx">         self._cachedObjectResources[name] = objectResource
</span><span class="cx"> 
</span><span class="cx">         # Update database
</span><del>-        self.retrieveOldIndex().addOrUpdateRecord(NotificationRecord(uid, name, xmltype.name))
</del><ins>+        self.retrieveOldIndex().addOrUpdateRecord(NotificationRecord(uid, name, xmltype))
</ins><span class="cx"> 
</span><span class="cx">         self.notifyChanged()
</span><span class="cx"> 
</span><span class="lines">@@ -1576,7 +1576,7 @@
</span><span class="cx"> 
</span><span class="cx">         rname = uid + &quot;.xml&quot;
</span><span class="cx">         self._parentCollection.retrieveOldIndex().addOrUpdateRecord(
</span><del>-            NotificationRecord(uid, rname, xmltype.name)
</del><ins>+            NotificationRecord(uid, rname, xmltype)
</ins><span class="cx">         )
</span><span class="cx"> 
</span><span class="cx">         self._xmldata = xmldata
</span></span></pre></div>
<a id="CalendarServerbranchesuserscdaboosharinginthestoretxdavcommondatastoresqlpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/sql.py (11944 => 11945)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/sql.py        2013-11-14 03:37:20 UTC (rev 11944)
+++ CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/sql.py        2013-11-14 03:47:16 UTC (rev 11945)
</span><span class="lines">@@ -50,7 +50,6 @@
</span><span class="cx"> from twisted.python.util import FancyEqMixin
</span><span class="cx"> 
</span><span class="cx"> from twistedcaldav.config import config
</span><del>-from twistedcaldav.customxml import NotificationType
</del><span class="cx"> from twistedcaldav.dateops import datetimeMktime, pyCalendarTodatetime
</span><span class="cx"> 
</span><span class="cx"> from txdav.base.datastore.util import QueryCacher
</span><span class="lines">@@ -72,7 +71,6 @@
</span><span class="cx"> from txdav.common.idirectoryservice import IStoreDirectoryService
</span><span class="cx"> from txdav.common.inotifications import INotificationCollection, \
</span><span class="cx">     INotificationObject
</span><del>-from txdav.xml.parser import WebDAVDocument
</del><span class="cx"> from txdav.idav import ChangeCategory
</span><span class="cx"> 
</span><span class="cx"> from uuid import uuid4, UUID
</span><span class="lines">@@ -639,6 +637,14 @@
</span><span class="cx">         return NotificationCollection.notificationsWithUID(self, uid, create)
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+    @memoizedKey(&quot;rid&quot;, &quot;_notificationHomes&quot;)
+    def notificationsWithResourceID(self, rid):
+        &quot;&quot;&quot;
+        Implement notificationsWithResourceID.
+        &quot;&quot;&quot;
+        return NotificationCollection.notificationsWithResourceID(self, rid)
+
+
</ins><span class="cx">     @classproperty
</span><span class="cx">     def _insertAPNSubscriptionQuery(cls): #@NoSelf
</span><span class="cx">         apn = schema.APN_SUBSCRIPTIONS
</span><span class="lines">@@ -4914,6 +4920,7 @@
</span><span class="cx">         self._txn = txn
</span><span class="cx">         self._uid = uid
</span><span class="cx">         self._resourceID = resourceID
</span><ins>+        self._dataVersion = None
</ins><span class="cx">         self._notifications = {}
</span><span class="cx">         self._notificationNames = None
</span><span class="cx">         self._syncTokenRevision = None
</span><span class="lines">@@ -4926,6 +4933,10 @@
</span><span class="cx">         [_homeSchema.RESOURCE_ID], From=_homeSchema,
</span><span class="cx">         Where=_homeSchema.OWNER_UID == Parameter(&quot;uid&quot;))
</span><span class="cx"> 
</span><ins>+    _UIDFromResourceIDQuery = Select(
+        [_homeSchema.OWNER_UID], From=_homeSchema,
+        Where=_homeSchema.RESOURCE_ID == Parameter(&quot;rid&quot;))
+
</ins><span class="cx">     _provisionNewNotificationsQuery = Insert(
</span><span class="cx">         {_homeSchema.OWNER_UID: Parameter(&quot;uid&quot;)},
</span><span class="cx">         Return=_homeSchema.RESOURCE_ID
</span><span class="lines">@@ -4984,7 +4995,20 @@
</span><span class="cx">         returnValue(collection)
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+    @classmethod
</ins><span class="cx">     @inlineCallbacks
</span><ins>+    def notificationsWithResourceID(cls, txn, rid):
+        rows = yield cls._UIDFromResourceIDQuery.on(txn, rid=rid)
+
+        if rows:
+            uid = rows[0][0]
+            result = (yield cls.notificationsWithUID(txn, uid, create=False))
+            returnValue(result)
+        else:
+            returnValue(None)
+
+
+    @inlineCallbacks
</ins><span class="cx">     def _loadPropertyStore(self):
</span><span class="cx">         self._propertyStore = yield PropertyStore.load(
</span><span class="cx">             self._uid,
</span><span class="lines">@@ -5009,6 +5033,23 @@
</span><span class="cx">         return self._resourceID
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+    @classproperty
+    def _dataVersionQuery(cls): #@NoSelf
+        nh = cls._homeSchema
+        return Select(
+            [nh.DATAVERSION], From=nh,
+            Where=nh.RESOURCE_ID == Parameter(&quot;resourceID&quot;)
+        )
+
+
+    @inlineCallbacks
+    def dataVersion(self):
+        if self._dataVersion is None:
+            self._dataVersion = (yield self._dataVersionQuery.on(
+                self._txn, resourceID=self._resourceID))[0][0]
+        returnValue(self._dataVersion)
+
+
</ins><span class="cx">     def name(self):
</span><span class="cx">         return &quot;notification&quot;
</span><span class="cx"> 
</span><span class="lines">@@ -5233,6 +5274,11 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> class NotificationObject(FancyEqMixin, object):
</span><ins>+    &quot;&quot;&quot;
+    This used to store XML data and an XML element for the type. But we are now switching it
+    to use JSON internally. The app layer will convert that to XML and fill in the &quot;blanks&quot; as
+    needed for the app.
+    &quot;&quot;&quot;
</ins><span class="cx">     log = Logger()
</span><span class="cx"> 
</span><span class="cx">     implements(INotificationObject)
</span><span class="lines">@@ -5266,12 +5312,12 @@
</span><span class="cx">         DAL query to load all columns by home ID.
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         obj = cls._objectSchema
</span><del>-        return Select([obj.RESOURCE_ID, obj.NOTIFICATION_UID, obj.MD5,
-                       Len(obj.XML_DATA), obj.XML_TYPE, obj.CREATED,
-                       obj.MODIFIED],
-                      From=obj,
-                      Where=(obj.NOTIFICATION_HOME_RESOURCE_ID == Parameter(
-                          &quot;homeID&quot;)))
</del><ins>+        return Select(
+            [obj.RESOURCE_ID, obj.NOTIFICATION_UID, obj.MD5,
+             Len(obj.XML_DATA), obj.XML_TYPE, obj.CREATED, obj.MODIFIED],
+            From=obj,
+            Where=(obj.NOTIFICATION_HOME_RESOURCE_ID == Parameter(&quot;homeID&quot;))
+        )
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @classmethod
</span><span class="lines">@@ -5434,20 +5480,20 @@
</span><span class="cx">         Set the object resource data and update and cached metadata.
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx"> 
</span><del>-        self._xmlType = NotificationType(xmltype)
</del><ins>+        self._xmlType = xmltype
</ins><span class="cx">         self._md5 = hashlib.md5(xmldata).hexdigest()
</span><span class="cx">         self._size = len(xmldata)
</span><span class="cx">         if inserting:
</span><span class="cx">             rows = yield self._newNotificationQuery.on(
</span><span class="cx">                 self._txn, homeID=self._home._resourceID, uid=uid,
</span><del>-                xmlType=self._xmlType.toxml(), xmlData=xmldata, md5=self._md5
</del><ins>+                xmlType=self._xmlType, xmlData=xmldata, md5=self._md5
</ins><span class="cx">             )
</span><span class="cx">             self._resourceID, self._created, self._modified = rows[0]
</span><span class="cx">             self._loadPropertyStore()
</span><span class="cx">         else:
</span><span class="cx">             rows = yield self._updateNotificationQuery.on(
</span><span class="cx">                 self._txn, homeID=self._home._resourceID, uid=uid,
</span><del>-                xmlType=self._xmlType.toxml(), xmlData=xmldata, md5=self._md5
</del><ins>+                xmlType=self._xmlType, xmlData=xmldata, md5=self._md5
</ins><span class="cx">             )
</span><span class="cx">             self._modified = rows[0][0]
</span><span class="cx">         self._objectText = xmldata
</span><span class="lines">@@ -5482,11 +5528,6 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     def xmlType(self):
</span><del>-        # NB This is the NotificationType property element
-        if isinstance(self._xmlType, str):
-            # Convert into NotificationType property element
-            self._xmlType = WebDAVDocument.fromString(self._xmlType).root_element
-
</del><span class="cx">         return self._xmlType
</span><span class="cx"> 
</span><span class="cx"> 
</span></span></pre></div>
<a id="CalendarServerbranchesuserscdaboosharinginthestoretxdavcommondatastoresql_schemacurrentoracledialectsql"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/sql_schema/current-oracle-dialect.sql (11944 => 11945)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/sql_schema/current-oracle-dialect.sql        2013-11-14 03:37:20 UTC (rev 11944)
+++ CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/sql_schema/current-oracle-dialect.sql        2013-11-14 03:47:16 UTC (rev 11945)
</span><span class="lines">@@ -49,7 +49,8 @@
</span><span class="cx"> 
</span><span class="cx"> create table NOTIFICATION_HOME (
</span><span class="cx">     &quot;RESOURCE_ID&quot; integer primary key,
</span><del>-    &quot;OWNER_UID&quot; nvarchar2(255) unique
</del><ins>+    &quot;OWNER_UID&quot; nvarchar2(255) unique,
+    &quot;DATAVERSION&quot; integer default 0 not null
</ins><span class="cx"> );
</span><span class="cx"> 
</span><span class="cx"> create table NOTIFICATION (
</span><span class="lines">@@ -367,9 +368,10 @@
</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', '28');
</del><ins>+insert into CALENDARSERVER (NAME, VALUE) values ('VERSION', '29');
</ins><span class="cx"> insert into CALENDARSERVER (NAME, VALUE) values ('CALENDAR-DATAVERSION', '5');
</span><span class="cx"> insert into CALENDARSERVER (NAME, VALUE) values ('ADDRESSBOOK-DATAVERSION', '2');
</span><ins>+insert into CALENDARSERVER (NAME, VALUE) values ('NOTIFICATION-DATAVERSION', '1');
</ins><span class="cx"> create index CALENDAR_HOME_METADAT_3cb9049e on CALENDAR_HOME_METADATA (
</span><span class="cx">     DEFAULT_EVENTS
</span><span class="cx"> );
</span></span></pre></div>
<a id="CalendarServerbranchesuserscdaboosharinginthestoretxdavcommondatastoresql_schemacurrentsql"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/sql_schema/current.sql (11944 => 11945)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/sql_schema/current.sql        2013-11-14 03:37:20 UTC (rev 11944)
+++ CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/sql_schema/current.sql        2013-11-14 03:47:16 UTC (rev 11945)
</span><span class="lines">@@ -109,7 +109,8 @@
</span><span class="cx"> 
</span><span class="cx"> create table NOTIFICATION_HOME (
</span><span class="cx">   RESOURCE_ID integer      primary key default nextval('RESOURCE_ID_SEQ'), -- implicit index
</span><del>-  OWNER_UID   varchar(255) not null unique                                 -- implicit index
</del><ins>+  OWNER_UID   varchar(255) not null unique,                                -- implicit index
+  DATAVERSION integer      default 0 not null
</ins><span class="cx"> );
</span><span class="cx"> 
</span><span class="cx"> create table NOTIFICATION (
</span><span class="lines">@@ -699,6 +700,7 @@
</span><span class="cx">   VALUE                         varchar(255)
</span><span class="cx"> );
</span><span class="cx"> 
</span><del>-insert into CALENDARSERVER values ('VERSION', '28');
</del><ins>+insert into CALENDARSERVER values ('VERSION', '29');
</ins><span class="cx"> insert into CALENDARSERVER values ('CALENDAR-DATAVERSION', '5');
</span><span class="cx"> insert into CALENDARSERVER values ('ADDRESSBOOK-DATAVERSION', '2');
</span><ins>+insert into CALENDARSERVER values ('NOTIFICATION-DATAVERSION', '1');
</ins></span></pre></div>
<a id="CalendarServerbranchesuserscdaboosharinginthestoretxdavcommondatastoresql_schemaoldoracledialectv28sql"></a>
<div class="addfile"><h4>Added: CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/sql_schema/old/oracle-dialect/v28.sql (0 => 11945)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/sql_schema/old/oracle-dialect/v28.sql                                (rev 0)
+++ CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/sql_schema/old/oracle-dialect/v28.sql        2013-11-14 03:47:16 UTC (rev 11945)
</span><span class="lines">@@ -0,0 +1,501 @@
</span><ins>+create sequence RESOURCE_ID_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 CALENDAR_HOME (
+    &quot;RESOURCE_ID&quot; integer primary key,
+    &quot;OWNER_UID&quot; nvarchar2(255) unique,
+    &quot;DATAVERSION&quot; integer default 0 not null
+);
+
+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
+);
+
+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;XML_TYPE&quot; nvarchar2(255),
+    &quot;XML_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;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);
+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);
+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', 
+    unique(&quot;CALENDAR_RESOURCE_ID&quot;, &quot;RESOURCE_NAME&quot;)
+);
+
+create table CALENDAR_OBJECT_ATTACHMENTS_MO (
+    &quot;ID&quot; integer primary key,
+    &quot;DESCRIPTION&quot; nvarchar2(16) unique
+);
+
+insert into CALENDAR_OBJECT_ATTACHMENTS_MO (DESCRIPTION, ID) values ('none', 0);
+insert into CALENDAR_OBJECT_ATTACHMENTS_MO (DESCRIPTION, ID) values ('read', 1);
+insert into CALENDAR_OBJECT_ATTACHMENTS_MO (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 TRANSPARENCY (
+    &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
+);
+
+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;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;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', 
+    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 references ADDRESSBOOK_OBJECT on delete cascade,
+    &quot;ADDRESSBOOK_ID&quot; integer not null references ADDRESSBOOK_HOME on delete cascade,
+    &quot;MEMBER_ID&quot; integer not null references ADDRESSBOOK_OBJECT, 
+    primary key(&quot;GROUP_ID&quot;, &quot;MEMBER_ID&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;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
+);
+
+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;RESOURCE_NAME&quot; nvarchar2(255),
+    &quot;REVISION&quot; integer not null,
+    &quot;DELETED&quot; integer not null
+);
+
+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, 
+    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;NOT_BEFORE&quot; timestamp default CURRENT_TIMESTAMP at time zone 'UTC',
+    &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;NOT_BEFORE&quot; timestamp default CURRENT_TIMESTAMP at time zone 'UTC'
+);
+
+create table IMIP_REPLY_WORK (
+    &quot;WORK_ID&quot; integer primary key not null,
+    &quot;NOT_BEFORE&quot; timestamp default CURRENT_TIMESTAMP at time zone 'UTC',
+    &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;NOT_BEFORE&quot; timestamp default CURRENT_TIMESTAMP at time zone 'UTC',
+    &quot;PUSH_ID&quot; nvarchar2(255),
+    &quot;PRIORITY&quot; integer not null
+);
+
+create table GROUP_CACHER_POLLING_WORK (
+    &quot;WORK_ID&quot; integer primary key not null,
+    &quot;NOT_BEFORE&quot; timestamp default CURRENT_TIMESTAMP at time zone 'UTC'
+);
+
+create table CALENDAR_OBJECT_SPLITTER_WORK (
+    &quot;WORK_ID&quot; integer primary key not null,
+    &quot;NOT_BEFORE&quot; timestamp default CURRENT_TIMESTAMP at time zone 'UTC',
+    &quot;RESOURCE_ID&quot; integer not null references CALENDAR_OBJECT 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', '28');
+insert into CALENDARSERVER (NAME, VALUE) values ('CALENDAR-DATAVERSION', '5');
+insert into CALENDARSERVER (NAME, VALUE) values ('ADDRESSBOOK-DATAVERSION', '2');
+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 TRANSPARENCY_TIME_RAN_5f34467f on TRANSPARENCY (
+    TIME_RANGE_INSTANCE_ID
+);
+
+create index ATTACHMENT_CALENDAR_H_0078845c on ATTACHMENT (
+    CALENDAR_HOME_RESOURCE_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 CALENDAR_OBJECT_SPLIT_af71dcda on CALENDAR_OBJECT_SPLITTER_WORK (
+    RESOURCE_ID
+);
+
</ins></span></pre></div>
<a id="CalendarServerbranchesuserscdaboosharinginthestoretxdavcommondatastoresql_schemaoldpostgresdialectv28sql"></a>
<div class="addfile"><h4>Added: CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/sql_schema/old/postgres-dialect/v28.sql (0 => 11945)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/sql_schema/old/postgres-dialect/v28.sql                                (rev 0)
+++ CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/sql_schema/old/postgres-dialect/v28.sql        2013-11-14 03:47:16 UTC (rev 11945)
</span><span class="lines">@@ -0,0 +1,704 @@
</span><ins>+-- -*- test-case-name: txdav.caldav.datastore.test.test_sql,txdav.carddav.datastore.test.test_sql -*-
+
+----
+-- Copyright (c) 2010-2013 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
+);
+
+
+-------------------
+-- 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
+  DATAVERSION      integer      default 0 not null
+);
+
+--------------
+-- 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
+);
+
+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,
+  XML_TYPE                      varchar(255) not null,
+  XML_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,
+  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');
+
+-- 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');
+
+
+-- 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_OBJECT_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),
+
+  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_OBJECT_ATTACHMENTS_MODE (
+  ID          integer     primary key,
+  DESCRIPTION varchar(16) not null unique
+);
+
+insert into CALENDAR_OBJECT_ATTACHMENTS_MODE values (0, 'none' );
+insert into CALENDAR_OBJECT_ATTACHMENTS_MODE values (1, 'read' );
+insert into CALENDAR_OBJECT_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'  );
+
+
+------------------
+-- Transparency --
+------------------
+
+create table TRANSPARENCY (
+  TIME_RANGE_INSTANCE_ID      integer      not null references TIME_RANGE on delete cascade,
+  USER_ID                     varchar(255) not null,
+  TRANSPARENT                 boolean      not null
+);
+
+create index TRANSPARENCY_TIME_RANGE_INSTANCE_ID on
+  TRANSPARENCY(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);
+
+-- 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
+  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,
+  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),
+
+  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');
+
+
+---------------------------------
+-- 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
+
+    primary key (GROUP_ID, MEMBER_ID) -- 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,
+  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
+);
+
+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,
+  RESOURCE_NAME                                        varchar(255),
+  REVISION                                             integer             default nextval('REVISION_SEQ') not null,
+  DELETED                                              boolean              not null
+);
+
+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,
+
+  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
+  NOT_BEFORE                    timestamp    default timezone('UTC', CURRENT_TIMESTAMP),
+  FROM_ADDR                     varchar(255) not null,
+  TO_ADDR                       varchar(255) not null,
+  ICALENDAR_TEXT                text         not null
+);
+
+
+-----------------------
+-- IMIP Polling Work --
+-----------------------
+
+create table IMIP_POLLING_WORK (
+  WORK_ID                       integer      primary key default nextval('WORKITEM_SEQ') not null, -- implicit index
+  NOT_BEFORE                    timestamp    default timezone('UTC', CURRENT_TIMESTAMP)
+);
+
+
+---------------------
+-- IMIP Reply Work --
+---------------------
+
+create table IMIP_REPLY_WORK (
+  WORK_ID                       integer      primary key default nextval('WORKITEM_SEQ') not null, -- implicit index
+  NOT_BEFORE                    timestamp    default timezone('UTC', CURRENT_TIMESTAMP),
+  ORGANIZER                     varchar(255) not null,
+  ATTENDEE                      varchar(255) not null,
+  ICALENDAR_TEXT                text         not null
+);
+
+
+------------------------
+-- Push Notifications --
+------------------------
+
+create table PUSH_NOTIFICATION_WORK (
+  WORK_ID                       integer      primary key default nextval('WORKITEM_SEQ') not null, -- implicit index
+  NOT_BEFORE                    timestamp    default timezone('UTC', CURRENT_TIMESTAMP),
+  PUSH_ID                       varchar(255) not null,
+  PRIORITY                      integer      not null -- 1:low 5:medium 10:high
+);
+
+-----------------
+-- GroupCacher --
+-----------------
+
+create table GROUP_CACHER_POLLING_WORK (
+  WORK_ID                       integer      primary key default nextval('WORKITEM_SEQ') not null, -- implicit index
+  NOT_BEFORE                    timestamp    default timezone('UTC', CURRENT_TIMESTAMP)
+);
+
+
+--------------------------
+-- Object Splitter Work --
+--------------------------
+
+create table CALENDAR_OBJECT_SPLITTER_WORK (
+  WORK_ID                       integer      primary key default nextval('WORKITEM_SEQ') not null, -- implicit index
+  NOT_BEFORE                    timestamp    default timezone('UTC', CURRENT_TIMESTAMP),
+  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);
+
+--------------------
+-- Schema Version --
+--------------------
+
+create table CALENDARSERVER (
+  NAME                          varchar(255) primary key, -- implicit index
+  VALUE                         varchar(255)
+);
+
+insert into CALENDARSERVER values ('VERSION', '28');
+insert into CALENDARSERVER values ('CALENDAR-DATAVERSION', '5');
+insert into CALENDARSERVER values ('ADDRESSBOOK-DATAVERSION', '2');
</ins></span></pre></div>
<a id="CalendarServerbranchesuserscdaboosharinginthestoretxdavcommondatastoresql_schemaupgradesoracledialectupgrade_from_28_to_29sql"></a>
<div class="addfile"><h4>Added: CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_28_to_29.sql (0 => 11945)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_28_to_29.sql                                (rev 0)
+++ CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_28_to_29.sql        2013-11-14 03:47:16 UTC (rev 11945)
</span><span class="lines">@@ -0,0 +1,27 @@
</span><ins>+----
+-- Copyright (c) 2012-2013 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 28 to 29 --
+---------------------------------------------------
+
+-- Push notification work related updates
+
+alter table NOTIFICATION_HOME
+ add (&quot;DATAVERSION&quot; integer default 0 not null);
+
+-- Now update the version
+update CALENDARSERVER set VALUE = '29' where NAME = 'VERSION';
</ins></span></pre></div>
<a id="CalendarServerbranchesuserscdaboosharinginthestoretxdavcommondatastoresql_schemaupgradespostgresdialectupgrade_from_28_to_29sql"></a>
<div class="addfile"><h4>Added: CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/sql_schema/upgrades/postgres-dialect/upgrade_from_28_to_29.sql (0 => 11945)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/sql_schema/upgrades/postgres-dialect/upgrade_from_28_to_29.sql                                (rev 0)
+++ CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/sql_schema/upgrades/postgres-dialect/upgrade_from_28_to_29.sql        2013-11-14 03:47:16 UTC (rev 11945)
</span><span class="lines">@@ -0,0 +1,27 @@
</span><ins>+----
+-- Copyright (c) 2012-2013 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 28 to 29 --
+---------------------------------------------------
+
+-- Push notification work related updates
+
+alter table NOTIFICATION_HOME
+  add column DATAVERSION integer default 0 not null;
+
+-- Now update the version
+update CALENDARSERVER set VALUE = '29' where NAME = 'VERSION';
</ins></span></pre></div>
<a id="CalendarServerbranchesuserscdaboosharinginthestoretxdavcommondatastoretestutilpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/test/util.py (11944 => 11945)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/test/util.py        2013-11-14 03:37:20 UTC (rev 11944)
+++ CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/test/util.py        2013-11-14 03:47:16 UTC (rev 11945)
</span><span class="lines">@@ -726,7 +726,7 @@
</span><span class="cx">         return &quot;/%s/%s/%s/&quot; % (prefix, self.hostname, id)
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-    def send(self, prefix, id, txn, priority): 
</del><ins>+    def send(self, prefix, id, txn, priority):
</ins><span class="cx">         self.history.append((self.pushKeyForId(prefix, id), priority))
</span><span class="cx"> 
</span><span class="cx"> 
</span></span></pre></div>
<a id="CalendarServerbranchesuserscdaboosharinginthestoretxdavcommondatastoreupgradesqlupgradepy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/upgrade/sql/upgrade.py (11944 => 11945)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/upgrade/sql/upgrade.py        2013-11-14 03:37:20 UTC (rev 11944)
+++ CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/upgrade/sql/upgrade.py        2013-11-14 03:47:16 UTC (rev 11945)
</span><span class="lines">@@ -414,6 +414,34 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+class UpgradeDatabaseNotificationDataStep(_UpgradeDatabaseDataStep):
+    &quot;&quot;&quot;
+    Checks and upgrades the database data. This assumes there are a bunch of
+    upgrade python modules that we can execute against the database to
+    accomplish the upgrade.
+
+    @ivar sqlStore: The store to operate on.
+
+    @type sqlStore: L{txdav.idav.IDataStore}
+    &quot;&quot;&quot;
+
+    def __init__(self, sqlStore, **kwargs):
+        &quot;&quot;&quot;
+        Initialize the service.
+
+        @param sqlStore: The store to operate on. Can be C{None} when doing unit tests.
+        @param service:  Wrapped service. Can be C{None} when doing unit tests.
+        &quot;&quot;&quot;
+        super(UpgradeDatabaseNotificationDataStep, self).__init__(sqlStore, **kwargs)
+
+        self.versionKey = &quot;NOTIFICATION-DATAVERSION&quot;
+        self.versionDescriptor = &quot;notification data&quot;
+        self.upgradeFilePrefix = &quot;notification_&quot;
+        self.upgradeFileSuffix = &quot;.py&quot;
+        self.defaultKeyValue = 0
+
+
+
</ins><span class="cx"> class UpgradeDatabaseOtherStep(UpgradeDatabaseCoreStep):
</span><span class="cx">     &quot;&quot;&quot;
</span><span class="cx">     Do any other upgrade behaviors once all the schema, data, file migration upgraders
</span></span></pre></div>
<a id="CalendarServerbranchesuserscdaboosharinginthestoretxdavcommondatastoreupgradesqlupgradesnotification_upgrade_from_0_to_1py"></a>
<div class="addfile"><h4>Added: CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/upgrade/sql/upgrades/notification_upgrade_from_0_to_1.py (0 => 11945)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/upgrade/sql/upgrades/notification_upgrade_from_0_to_1.py                                (rev 0)
+++ CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/upgrade/sql/upgrades/notification_upgrade_from_0_to_1.py        2013-11-14 03:47:16 UTC (rev 11945)
</span><span class="lines">@@ -0,0 +1,168 @@
</span><ins>+# -*- test-case-name: txdav.common.datastore.upgrade.sql.test -*-
+##
+# Copyright (c) 2013 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.
+##
+
+from twisted.internet.defer import inlineCallbacks
+
+from twistedcaldav import caldavxml, customxml
+from twistedcaldav.config import config
+
+from txdav.common.datastore.sql_tables import schema, _BIND_STATUS_INVITED
+from txdav.common.datastore.upgrade.sql.upgrades.util import updateNotificationDataVersion, \
+    doToEachHomeNotAtVersion
+from txdav.xml import element
+from txdav.xml.parser import WebDAVDocument
+from twistedcaldav.sharing import invitationBindStatusFromXMLMap, \
+    invitationBindModeFromXMLMap
+import json
+
+&quot;&quot;&quot;
+Data upgrade from database version 0 to 1
+&quot;&quot;&quot;
+
+UPGRADE_TO_VERSION = 1
+
+@inlineCallbacks
+def doUpgrade(sqlStore):
+    &quot;&quot;&quot;
+    Do the required upgrade steps.
+    &quot;&quot;&quot;
+    yield updateNotificationHomes(sqlStore, config.UpgradeHomePrefix)
+
+    # Don't do remaining upgrade if we are only process a subset of the homes
+    if not config.UpgradeHomePrefix:
+        # Always bump the DB value
+        yield updateNotificationDataVersion(sqlStore, UPGRADE_TO_VERSION)
+
+
+
+@inlineCallbacks
+def updateNotificationHomes(sqlStore, prefix=None):
+    &quot;&quot;&quot;
+    For each calendar home, update the associated properties on the home or its owned calendars.
+    &quot;&quot;&quot;
+
+    yield doToEachHomeNotAtVersion(sqlStore, schema.NOTIFICATION_HOME, UPGRADE_TO_VERSION, updateNotificationHome, &quot;Update Notification Home&quot;, filterOwnerUID=prefix)
+
+
+
+@inlineCallbacks
+def updateNotificationHome(txn, homeResourceID):
+    &quot;&quot;&quot;
+    For this notification home, update the associated child resources.
+    &quot;&quot;&quot;
+
+    home = yield txn.notificationsWithResourceID(homeResourceID)
+    notifications = (yield home.notificationObjects())
+    for notification in notifications:
+        yield updateNotification(txn, notification)
+
+
+
+@inlineCallbacks
+def updateNotification(txn, notification):
+    &quot;&quot;&quot;
+    For this notification home, update the associated child resources.
+    &quot;&quot;&quot;
+
+    # Convert the type value to JSON
+    xmltype = WebDAVDocument.fromString(notification._xmlType).root_element
+    shared_type = &quot;calendar&quot;
+    if xmltype.children[0].qname() == customxml.InviteNotification.qname():
+        jsontype = {&quot;notification-type&quot;: &quot;invite-notification&quot;}
+        if &quot;shared-type&quot; in xmltype.children[0].attributes:
+            shared_type = xmltype.children[0].attributes[&quot;shared-type&quot;]
+        jsontype[&quot;shared-type&quot;] = shared_type
+    elif xmltype.children[0].qname() == customxml.InviteReply.qname():
+        jsontype = {&quot;notification-type&quot;: &quot;invite-reply&quot;}
+
+    # Convert the data value to JSON
+    xmldata = (yield notification.xmldata())
+    xmldata = WebDAVDocument.fromString(xmldata).root_element
+
+    def _extract_UID(uri):
+        if uri.startswith(&quot;urn:uuid:&quot;):
+            return uri[len(&quot;urn:uuid:&quot;):]
+        elif uri[0] == &quot;/&quot;:
+            return uri.rstrip(&quot;/&quot;).split(&quot;/&quot;)[-1]
+        elif uri.startswith(&quot;mailto:&quot;):
+            return uri[7:].split(&quot;@&quot;)[0]
+        else:
+            return &quot;&quot;
+
+    if xmldata.childOfType(customxml.InviteNotification) is not None:
+        ntype = xmldata.childOfType(customxml.InviteNotification)
+        dtstamp = str(xmldata.childOfType(customxml.DTStamp))
+        owner = _extract_UID(str(ntype.childOfType(customxml.Organizer).childOfType(element.HRef)))
+        sharee = _extract_UID(str(ntype.childOfType(element.HRef)))
+        uid = str(ntype.childOfType(customxml.UID))
+        for xml in invitationBindStatusFromXMLMap.keys():
+            if ntype.childOfType(xml) is not None:
+                state = invitationBindStatusFromXMLMap[xml]
+                break
+        else:
+            state = _BIND_STATUS_INVITED
+        mode = invitationBindModeFromXMLMap[type(ntype.childOfType(customxml.InviteAccess).children[0])]
+        name = str(ntype.childOfType(customxml.HostURL).childOfType(element.HRef)).rstrip(&quot;/&quot;).split(&quot;/&quot;)[-1]
+        summary = str(ntype.childOfType(customxml.InviteSummary))
+
+        jsondata = {
+            &quot;notification-type&quot;: &quot;invite-notification&quot;,
+            &quot;shared-type&quot;: shared_type,
+            &quot;dtstamp&quot;: dtstamp,
+            &quot;owner&quot;: owner,
+            &quot;sharee&quot;: sharee,
+            &quot;uid&quot;: uid,
+            &quot;status&quot;: state,
+            &quot;access&quot;: mode,
+            &quot;name&quot;: name,
+            &quot;summary&quot;: summary,
+        }
+        if ntype.childOfType(caldavxml.SupportedCalendarComponentSet):
+            comps = [child.attributes[&quot;name&quot;] for child in ntype.childOfType(caldavxml.SupportedCalendarComponentSet).children]
+            jsondata[&quot;supported-components&quot;] = &quot;,&quot;.join(comps)
+
+    elif xmldata.childOfType(customxml.InviteReply) is not None:
+        ntype = xmldata.childOfType(customxml.InviteReply)
+        dtstamp = str(xmldata.childOfType(customxml.DTStamp))
+        sharee = _extract_UID(str(ntype.childOfType(element.HRef)))
+        for xml in invitationBindStatusFromXMLMap.keys():
+            if ntype.childOfType(xml) is not None:
+                state = invitationBindStatusFromXMLMap[xml]
+                break
+        else:
+            state = _BIND_STATUS_INVITED
+        name = str(ntype.childOfType(customxml.HostURL).childOfType(element.HRef)).rstrip(&quot;/&quot;).split(&quot;/&quot;)[-1]
+        inreplyto = str(ntype.childOfType(customxml.InReplyTo))
+        summary = str(ntype.childOfType(customxml.InviteSummary)) if ntype.childOfType(customxml.InviteSummary) is not None else &quot;&quot;
+
+        owner = str(ntype.childOfType(customxml.HostURL).childOfType(element.HRef)).rstrip(&quot;/&quot;).split(&quot;/&quot;)[-2]
+
+        jsondata = {
+            &quot;notification-type&quot;: &quot;invite-reply&quot;,
+            &quot;shared-type&quot;: shared_type,
+            &quot;dtstamp&quot;: dtstamp,
+            &quot;owner&quot;: owner,
+            &quot;sharee&quot;: sharee,
+            &quot;status&quot;: state,
+            &quot;name&quot;: name,
+            &quot;in-reply-to&quot;: inreplyto,
+            &quot;summary&quot;: summary,
+        }
+
+    jsontype = json.dumps(jsontype)
+    jsondata = json.dumps(jsondata)
+    yield notification.setData(notification.uid(), jsontype, jsondata)
</ins></span></pre></div>
<a id="CalendarServerbranchesuserscdaboosharinginthestoretxdavcommondatastoreupgradesqlupgradestesttest_notification_upgrade_from_0_to_1py"></a>
<div class="addfile"><h4>Added: CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/upgrade/sql/upgrades/test/test_notification_upgrade_from_0_to_1.py (0 => 11945)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/upgrade/sql/upgrades/test/test_notification_upgrade_from_0_to_1.py                                (rev 0)
+++ CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/upgrade/sql/upgrades/test/test_notification_upgrade_from_0_to_1.py        2013-11-14 03:47:16 UTC (rev 11945)
</span><span class="lines">@@ -0,0 +1,196 @@
</span><ins>+##
+# Copyright (c) 2013 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.
+##
+
+from twext.enterprise.dal.syntax import Update
+
+from twisted.internet.defer import inlineCallbacks
+
+from txdav.caldav.datastore.test.util import CommonStoreTests
+from txdav.common.datastore.sql_tables import _BIND_STATUS_INVITED, \
+    _BIND_MODE_WRITE, _BIND_STATUS_ACCEPTED, _BIND_MODE_READ
+from txdav.common.datastore.upgrade.sql.upgrades.notification_upgrade_from_0_to_1 import doUpgrade
+
+import json
+
+&quot;&quot;&quot;
+Tests for L{txdav.common.datastore.upgrade.sql.upgrade}.
+&quot;&quot;&quot;
+
+class Upgrade_from_0_to_1(CommonStoreTests):
+    &quot;&quot;&quot;
+    Tests for notification upgrade.
+    &quot;&quot;&quot;
+
+    @inlineCallbacks
+    def test_upgrade_invite(self):
+
+        data = (
+            (
+                &quot;uid1&quot;,
+                &quot;&quot;&quot;&lt;?xml version='1.0' encoding='UTF-8'?&gt;
+&lt;CS:notification xmlns:CS='http://calendarserver.org/ns/'&gt;
+    &lt;CS:invite-notification shared-type='calendar'/&gt;
+&lt;/CS:notification&gt;
+&quot;&quot;&quot;,
+                {
+                    &quot;notification-type&quot;: &quot;invite-notification&quot;,
+                    &quot;shared-type&quot;: &quot;calendar&quot;,
+                },
+                &quot;&quot;&quot;&lt;?xml version='1.0' encoding='UTF-8'?&gt;
+&lt;notification xmlns='http://calendarserver.org/ns/'&gt;
+  &lt;dtstamp&gt;20131113T153109Z&lt;/dtstamp&gt;
+  &lt;invite-notification shared-type='calendar'&gt;
+    &lt;uid&gt;uid1&lt;/uid&gt;
+    &lt;href xmlns='DAV:'&gt;urn:uuid:user02&lt;/href&gt;
+    &lt;invite-noresponse/&gt;
+    &lt;access&gt;
+      &lt;read-write/&gt;
+    &lt;/access&gt;
+    &lt;hosturl&gt;
+      &lt;href xmlns='DAV:'&gt;/calendars/__uids__/user01/calendar&lt;/href&gt;
+    &lt;/hosturl&gt;
+    &lt;organizer&gt;
+      &lt;href xmlns='DAV:'&gt;urn:uuid:user01&lt;/href&gt;
+      &lt;common-name&gt;User 01&lt;/common-name&gt;
+    &lt;/organizer&gt;
+    &lt;summary&gt;Shared&lt;/summary&gt;
+    &lt;supported-calendar-component-set xmlns='urn:ietf:params:xml:ns:caldav'&gt;
+      &lt;comp name='VEVENT'/&gt;
+      &lt;comp name='VTODO'/&gt;
+    &lt;/supported-calendar-component-set&gt;
+  &lt;/invite-notification&gt;
+&lt;/notification&gt;
+&quot;&quot;&quot;,
+                {
+                    &quot;notification-type&quot;: &quot;invite-notification&quot;,
+                    &quot;shared-type&quot;: &quot;calendar&quot;,
+                    &quot;dtstamp&quot;: &quot;20131113T153109Z&quot;,
+                    &quot;owner&quot;: &quot;user01&quot;,
+                    &quot;sharee&quot;: &quot;user02&quot;,
+                    &quot;uid&quot;: &quot;uid1&quot;,
+                    &quot;status&quot;: _BIND_STATUS_INVITED,
+                    &quot;access&quot;: _BIND_MODE_WRITE,
+                    &quot;name&quot;: &quot;calendar&quot;,
+                    &quot;summary&quot;: &quot;Shared&quot;,
+                    &quot;supported-components&quot;: &quot;VEVENT,VTODO&quot;,
+                },
+            ),
+            (
+                &quot;uid2&quot;,
+                &quot;&quot;&quot;&lt;?xml version='1.0' encoding='UTF-8'?&gt;
+&lt;CS:notification xmlns:CS='http://calendarserver.org/ns/'&gt;
+    &lt;CS:invite-notification shared-type='addressbook'/&gt;
+&lt;/CS:notification&gt;
+&quot;&quot;&quot;,
+                {
+                    &quot;notification-type&quot;: &quot;invite-notification&quot;,
+                    &quot;shared-type&quot;: &quot;addressbook&quot;,
+                },
+                &quot;&quot;&quot;&lt;?xml version='1.0' encoding='UTF-8'?&gt;
+&lt;notification xmlns='http://calendarserver.org/ns/'&gt;
+  &lt;dtstamp&gt;20131113T153110Z&lt;/dtstamp&gt;
+  &lt;invite-notification shared-type='addressbook'&gt;
+    &lt;uid&gt;uid2&lt;/uid&gt;
+    &lt;href xmlns='DAV:'&gt;/principals/users/user02/&lt;/href&gt;
+    &lt;invite-accepted/&gt;
+    &lt;access&gt;
+      &lt;read/&gt;
+    &lt;/access&gt;
+    &lt;hosturl&gt;
+      &lt;href xmlns='DAV:'&gt;/addressbooks/__uids__/user01/addressbook/&lt;/href&gt;
+    &lt;/hosturl&gt;
+    &lt;organizer&gt;
+      &lt;href xmlns='DAV:'&gt;/principals/users/user01/&lt;/href&gt;
+      &lt;common-name&gt;User 01&lt;/common-name&gt;
+    &lt;/organizer&gt;
+    &lt;summary&gt;Shared 2&lt;/summary&gt;
+  &lt;/invite-notification&gt;
+&lt;/notification&gt;
+&quot;&quot;&quot;,
+                {
+                    &quot;notification-type&quot;: &quot;invite-notification&quot;,
+                    &quot;shared-type&quot;: &quot;addressbook&quot;,
+                    &quot;dtstamp&quot;: &quot;20131113T153110Z&quot;,
+                    &quot;owner&quot;: &quot;user01&quot;,
+                    &quot;sharee&quot;: &quot;user02&quot;,
+                    &quot;uid&quot;: &quot;uid2&quot;,
+                    &quot;status&quot;: _BIND_STATUS_ACCEPTED,
+                    &quot;access&quot;: _BIND_MODE_READ,
+                    &quot;name&quot;: &quot;addressbook&quot;,
+                    &quot;summary&quot;: &quot;Shared 2&quot;,
+                },
+            ),
+            (
+                &quot;uid3&quot;,
+                &quot;&quot;&quot;&lt;?xml version='1.0' encoding='UTF-8'?&gt;
+&lt;CS:notification xmlns:CS='http://calendarserver.org/ns/'&gt;
+    &lt;CS:invite-reply/&gt;
+&lt;/CS:notification&gt;
+&quot;&quot;&quot;,
+                {
+                    &quot;notification-type&quot;: &quot;invite-reply&quot;,
+                },
+                &quot;&quot;&quot;&lt;?xml version='1.0' encoding='UTF-8'?&gt;
+&lt;notification xmlns='http://calendarserver.org/ns/'&gt;
+  &lt;dtstamp&gt;20131113T153111Z&lt;/dtstamp&gt;
+  &lt;invite-reply shared-type='calendar'&gt;
+    &lt;href xmlns='DAV:'&gt;mailto:user02@example.com&lt;/href&gt;
+    &lt;invite-accepted/&gt;
+    &lt;hosturl&gt;
+      &lt;href xmlns='DAV:'&gt;/calendars/__uids__/user01/calendar&lt;/href&gt;
+    &lt;/hosturl&gt;
+    &lt;in-reply-to&gt;uid1&lt;/in-reply-to&gt;
+  &lt;/invite-reply&gt;
+&lt;/notification&gt;
+&quot;&quot;&quot;,
+                {
+                    &quot;notification-type&quot;: &quot;invite-reply&quot;,
+                    &quot;shared-type&quot;: &quot;calendar&quot;,
+                    &quot;dtstamp&quot;: &quot;20131113T153111Z&quot;,
+                    &quot;owner&quot;: &quot;user01&quot;,
+                    &quot;sharee&quot;: &quot;user02&quot;,
+                    &quot;status&quot;: _BIND_STATUS_ACCEPTED,
+                    &quot;name&quot;: &quot;calendar&quot;,
+                    &quot;in-reply-to&quot;: &quot;uid1&quot;,
+                    &quot;summary&quot;: &quot;&quot;,
+                },
+            ),
+        )
+
+        for uid, xmltype, _ignore_jtype, xmldata, _ignore_jdata in data:
+            notifications = yield self.transactionUnderTest().notificationsWithUID(&quot;user01&quot;)
+            yield notifications.writeNotificationObject(uid, xmltype, xmldata)
+
+        # Force data version to previous
+        nh = notifications._homeSchema
+        yield Update(
+            {nh.DATAVERSION: 0},
+            Where=None,
+        ).on(self.transactionUnderTest())
+
+        yield self.commit()
+        yield doUpgrade(self._sqlCalendarStore)
+
+        notifications = yield self.transactionUnderTest().notificationsWithUID(&quot;user01&quot;)
+        version = (yield notifications.dataVersion())
+        self.assertEqual(version, 1)
+
+        for uid, _ignore_xmltype, jtype, _ignore_xmldata, jdata in data:
+            notification = (yield notifications.notificationObjectWithUID(uid))
+            self.assertTrue(notification is not None, msg=&quot;Failed {uid}&quot;.format(uid=uid))
+            self.assertEqual(json.loads(notification.xmlType()), jtype, msg=&quot;Failed {uid}&quot;.format(uid=uid))
+            data = (yield notification.xmldata())
+            self.assertEqual(json.loads(data), jdata, msg=&quot;Failed {uid}&quot;.format(uid=uid))
</ins></span></pre></div>
<a id="CalendarServerbranchesuserscdaboosharinginthestoretxdavcommondatastoreupgradesqlupgradesutilpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/upgrade/sql/upgrades/util.py (11944 => 11945)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/upgrade/sql/upgrades/util.py        2013-11-14 03:37:20 UTC (rev 11944)
+++ CalendarServer/branches/users/cdaboo/sharing-in-the-store/txdav/common/datastore/upgrade/sql/upgrades/util.py        2013-11-14 03:47:16 UTC (rev 11945)
</span><span class="lines">@@ -128,6 +128,11 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+def updateNotificationDataVersion(store, version):
+    return _updateDataVersion(store, &quot;NOTIFICATION-DATAVERSION&quot;, version)
+
+
+
</ins><span class="cx"> @inlineCallbacks
</span><span class="cx"> def doToEachHomeNotAtVersion(store, homeSchema, version, doIt, logStr, filterOwnerUID=None):
</span><span class="cx">     &quot;&quot;&quot;
</span></span></pre>
</div>
</div>

</body>
</html>