<!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>[12041] CalendarServer/branches/users/cdaboo/cross-pod-sharing</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/12041">12041</a></dd>
<dt>Author</dt> <dd>cdaboo@apple.com</dd>
<dt>Date</dt> <dd>2013-12-06 13:43:35 -0800 (Fri, 06 Dec 2013)</dd>
</dl>

<h3>Log Message</h3>
<pre>Initial work on cross-pod sharing. This supports the round-tripping of invites across pods with appropriate
bind table entries so that shared collections appear on the sharee side. Access to actual data in the shared
resource is the next thing to be done.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#CalendarServerbranchesuserscdaboocrosspodsharingcalendarservertapcaldavpy">CalendarServer/branches/users/cdaboo/cross-pod-sharing/calendarserver/tap/caldav.py</a></li>
<li><a href="#CalendarServerbranchesuserscdaboocrosspodsharingcalendarservertaputilpy">CalendarServer/branches/users/cdaboo/cross-pod-sharing/calendarserver/tap/util.py</a></li>
<li><a href="#CalendarServerbranchesuserscdaboocrosspodsharingconfcaldavdtestpodBplist">CalendarServer/branches/users/cdaboo/cross-pod-sharing/conf/caldavd-test-podB.plist</a></li>
<li><a href="#CalendarServerbranchesuserscdaboocrosspodsharingtwextweb2httppy">CalendarServer/branches/users/cdaboo/cross-pod-sharing/twext/web2/http.py</a></li>
<li><a href="#CalendarServerbranchesuserscdaboocrosspodsharingtwistedpluginscaldavpy">CalendarServer/branches/users/cdaboo/cross-pod-sharing/twisted/plugins/caldav.py</a></li>
<li><a href="#CalendarServerbranchesuserscdaboocrosspodsharingtwistedcaldavstdconfigpy">CalendarServer/branches/users/cdaboo/cross-pod-sharing/twistedcaldav/stdconfig.py</a></li>
<li><a href="#CalendarServerbranchesuserscdaboocrosspodsharingtxdavbasedatastoresubpostgrespy">CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/base/datastore/subpostgres.py</a></li>
<li><a href="#CalendarServerbranchesuserscdaboocrosspodsharingtxdavbasedatastoreutilpy">CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/base/datastore/util.py</a></li>
<li><a href="#CalendarServerbranchesuserscdaboocrosspodsharingtxdavcaldavdatastoreschedulingischedulelocalserverspy">CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/caldav/datastore/scheduling/ischedule/localservers.py</a></li>
<li><a href="#CalendarServerbranchesuserscdaboocrosspodsharingtxdavcaldavdatastoresqlpy">CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/caldav/datastore/sql.py</a></li>
<li><a href="#CalendarServerbranchesuserscdaboocrosspodsharingtxdavcaldavicalendardirectoryservicepy">CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/caldav/icalendardirectoryservice.py</a></li>
<li><a href="#CalendarServerbranchesuserscdaboocrosspodsharingtxdavcarddavdatastoresqlpy">CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/carddav/datastore/sql.py</a></li>
<li><a href="#CalendarServerbranchesuserscdaboocrosspodsharingtxdavcommondatastoresqlpy">CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/sql.py</a></li>
<li><a href="#CalendarServerbranchesuserscdaboocrosspodsharingtxdavcommondatastoresql_schemacurrentoracledialectsql">CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/sql_schema/current-oracle-dialect.sql</a></li>
<li><a href="#CalendarServerbranchesuserscdaboocrosspodsharingtxdavcommondatastoresql_schemacurrentsql">CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/sql_schema/current.sql</a></li>
<li><a href="#CalendarServerbranchesuserscdaboocrosspodsharingtxdavcommondatastoresql_tablespy">CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/sql_tables.py</a></li>
<li><a href="#CalendarServerbranchesuserscdaboocrosspodsharingtxdavcommonicommondatastorepy">CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/icommondatastore.py</a></li>
<li><a href="#CalendarServerbranchesuserscdaboocrosspodsharingtxdavcommonidirectoryservicepy">CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/idirectoryservice.py</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li>CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/podding/</li>
<li><a href="#CalendarServerbranchesuserscdaboocrosspodsharingtxdavcommondatastorepodding__init__py">CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/podding/__init__.py</a></li>
<li><a href="#CalendarServerbranchesuserscdaboocrosspodsharingtxdavcommondatastorepoddingconduitpy">CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/podding/conduit.py</a></li>
<li><a href="#CalendarServerbranchesuserscdaboocrosspodsharingtxdavcommondatastorepoddingrequestpy">CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/podding/request.py</a></li>
<li><a href="#CalendarServerbranchesuserscdaboocrosspodsharingtxdavcommondatastorepoddingresourcepy">CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/podding/resource.py</a></li>
<li>CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/podding/test/</li>
<li><a href="#CalendarServerbranchesuserscdaboocrosspodsharingtxdavcommondatastorepoddingtest__init__py">CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/podding/test/__init__.py</a></li>
<li><a href="#CalendarServerbranchesuserscdaboocrosspodsharingtxdavcommondatastorepoddingtesttest_conduitpy">CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/podding/test/test_conduit.py</a></li>
<li><a href="#CalendarServerbranchesuserscdaboocrosspodsharingtxdavcommondatastorepoddingtesttest_external_homepy">CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/podding/test/test_external_home.py</a></li>
<li><a href="#CalendarServerbranchesuserscdaboocrosspodsharingtxdavcommondatastorepoddingtesttest_resourcepy">CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/podding/test/test_resource.py</a></li>
<li><a href="#CalendarServerbranchesuserscdaboocrosspodsharingtxdavcommondatastoresql_schemaoldoracledialectv29sql">CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/sql_schema/old/oracle-dialect/v29.sql</a></li>
<li><a href="#CalendarServerbranchesuserscdaboocrosspodsharingtxdavcommondatastoresql_schemaoldpostgresdialectv29sql">CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/sql_schema/old/postgres-dialect/v29.sql</a></li>
<li><a href="#CalendarServerbranchesuserscdaboocrosspodsharingtxdavcommondatastoresql_schemaupgradesoracledialectupgrade_from_29_to_30sql">CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_29_to_30.sql</a></li>
<li><a href="#CalendarServerbranchesuserscdaboocrosspodsharingtxdavcommondatastoresql_schemaupgradespostgresdialectupgrade_from_29_to_30sql">CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/sql_schema/upgrades/postgres-dialect/upgrade_from_29_to_30.sql</a></li>
</ul>

<h3>Property Changed</h3>
<ul>
<li><a href="#CalendarServerbranchesuserscdaboocrosspodsharing">CalendarServer/branches/users/cdaboo/cross-pod-sharing/</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalendarServerbranchesuserscdaboocrosspodsharing"></a>
<div class="propset"><h4>Property changes: CalendarServer/branches/users/cdaboo/cross-pod-sharing</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/sharing-in-the-store:11935-12016
</span><span class="cx">/CalendarServer/branches/users/cdaboo/store-scheduling:10876-11129
</span><span class="cx">/CalendarServer/branches/users/cdaboo/timezones:7443-7699
</span><span class="cx">/CalendarServer/branches/users/cdaboo/txn-debugging:8730-8743
</span><span class="cx">/CalendarServer/branches/users/gaya/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/release/CalendarServer-5.2-dev:11972
</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/sharing-in-the-store:11935-12016
</span><span class="cx">/CalendarServer/branches/users/cdaboo/store-scheduling:10876-11129
</span><span class="cx">/CalendarServer/branches/users/cdaboo/timezones:7443-7699
</span><span class="cx">/CalendarServer/branches/users/cdaboo/txn-debugging:8730-8743
</span><span class="cx">/CalendarServer/branches/users/gaya/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><a id="CalendarServerbranchesuserscdaboocrosspodsharingcalendarservertapcaldavpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/cross-pod-sharing/calendarserver/tap/caldav.py (12040 => 12041)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/cross-pod-sharing/calendarserver/tap/caldav.py        2013-12-06 20:40:44 UTC (rev 12040)
+++ CalendarServer/branches/users/cdaboo/cross-pod-sharing/calendarserver/tap/caldav.py        2013-12-06 21:43:35 UTC (rev 12041)
</span><span class="lines">@@ -1691,11 +1691,9 @@
</span><span class="cx">                 raise StoreNotAvailable()
</span><span class="cx"> 
</span><span class="cx">             from twisted.internet import reactor
</span><del>-            pool = PeerConnectionPool(reactor, store.newTransaction,
-                                      7654, schema)
</del><ins>+            pool = PeerConnectionPool(reactor, store.newTransaction, config.WorkQueue.ampPort, schema)
</ins><span class="cx">             store.queuer = store.queuer.transferProposalCallbacks(pool)
</span><del>-            controlSocket.addFactory(_QUEUE_ROUTE,
-                                     pool.workerListenerFactory())
</del><ins>+            controlSocket.addFactory(_QUEUE_ROUTE, pool.workerListenerFactory())
</ins><span class="cx">             # TODO: now that we have the shared control socket, we should get
</span><span class="cx">             # rid of the connection dispenser and make a shared / async
</span><span class="cx">             # connection pool implementation that can dispense transactions
</span></span></pre></div>
<a id="CalendarServerbranchesuserscdaboocrosspodsharingcalendarservertaputilpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/cross-pod-sharing/calendarserver/tap/util.py (12040 => 12041)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/cross-pod-sharing/calendarserver/tap/util.py        2013-12-06 20:40:44 UTC (rev 12040)
+++ CalendarServer/branches/users/cdaboo/cross-pod-sharing/calendarserver/tap/util.py        2013-12-06 21:43:35 UTC (rev 12041)
</span><span class="lines">@@ -92,6 +92,7 @@
</span><span class="cx"> from calendarserver.webadmin.resource import WebAdminResource
</span><span class="cx"> from calendarserver.webcal.resource import WebCalendarResource
</span><span class="cx"> 
</span><ins>+from txdav.common.datastore.podding.resource import ConduitResource
</ins><span class="cx"> from txdav.common.datastore.sql import CommonDataStore as CommonSQLDataStore
</span><span class="cx"> from txdav.common.datastore.file import CommonDataStore as CommonFileDataStore
</span><span class="cx"> from txdav.common.datastore.sql import current_sql_schema
</span><span class="lines">@@ -407,6 +408,7 @@
</span><span class="cx">     rootResourceClass = RootResource
</span><span class="cx">     calendarResourceClass = DirectoryCalendarHomeProvisioningResource
</span><span class="cx">     iScheduleResourceClass = IScheduleInboxResource
</span><ins>+    conduitResourceClass = ConduitResource
</ins><span class="cx">     timezoneServiceResourceClass = TimezoneServiceResource
</span><span class="cx">     timezoneStdServiceResourceClass = TimezoneStdServiceResource
</span><span class="cx">     webCalendarResourceClass = WebCalendarResource
</span><span class="lines">@@ -636,7 +638,7 @@
</span><span class="cx">             addSystemEventTrigger(&quot;after&quot;, &quot;startup&quot;, timezoneStdService.onStartup)
</span><span class="cx"> 
</span><span class="cx">     #
</span><del>-    # iSchedule service for podding
</del><ins>+    # iSchedule/cross-pod service for podding
</ins><span class="cx">     #
</span><span class="cx">     if config.Servers.Enabled:
</span><span class="cx">         log.info(&quot;Setting up iSchedule podding inbox resource: {cls}&quot;, cls=iScheduleResourceClass)
</span><span class="lines">@@ -648,6 +650,14 @@
</span><span class="cx">         )
</span><span class="cx">         root.putChild(config.Servers.InboxName, ischedule)
</span><span class="cx"> 
</span><ins>+        log.info(&quot;Setting up podding conduit resource: {cls}&quot;, cls=conduitResourceClass)
+
+        conduit = conduitResourceClass(
+            root,
+            newStore,
+        )
+        root.putChild(config.Servers.ConduitName, conduit)
+
</ins><span class="cx">     #
</span><span class="cx">     # iSchedule service (not used for podding)
</span><span class="cx">     #
</span></span></pre></div>
<a id="CalendarServerbranchesuserscdaboocrosspodsharingconfcaldavdtestpodBplist"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/cross-pod-sharing/conf/caldavd-test-podB.plist (12040 => 12041)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/cross-pod-sharing/conf/caldavd-test-podB.plist        2013-12-06 20:40:44 UTC (rev 12040)
+++ CalendarServer/branches/users/cdaboo/cross-pod-sharing/conf/caldavd-test-podB.plist        2013-12-06 21:43:35 UTC (rev 12041)
</span><span class="lines">@@ -43,6 +43,13 @@
</span><span class="cx">     &lt;array&gt;
</span><span class="cx">     &lt;/array&gt;
</span><span class="cx"> 
</span><ins>+        &lt;!--  Work Queue --&gt;
+        &lt;key&gt;WorkQueue&lt;/key&gt;
+        &lt;dict&gt;
+                &lt;key&gt;ampPort&lt;/key&gt;
+                &lt;integer&gt;7655&lt;/integer&gt;
+        &lt;/dict&gt;
+
</ins><span class="cx">     &lt;!-- Server root --&gt;
</span><span class="cx">     &lt;key&gt;ServerRoot&lt;/key&gt;
</span><span class="cx">     &lt;string&gt;./data/podB&lt;/string&gt;
</span></span></pre></div>
<a id="CalendarServerbranchesuserscdaboocrosspodsharingtwextweb2httppy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/cross-pod-sharing/twext/web2/http.py (12040 => 12041)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/cross-pod-sharing/twext/web2/http.py        2013-12-06 20:40:44 UTC (rev 12040)
+++ CalendarServer/branches/users/cdaboo/cross-pod-sharing/twext/web2/http.py        2013-12-06 21:43:35 UTC (rev 12041)
</span><span class="lines">@@ -558,7 +558,7 @@
</span><span class="cx">     &quot;&quot;&quot;
</span><span class="cx">     def __init__(self, code, jobj):
</span><span class="cx">         &quot;&quot;&quot;
</span><del>-        @param xml_responses: an iterable of davxml.Response objects.
</del><ins>+        @param jobj: a Python object that can be serialized to JSON.
</ins><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         Response.__init__(self, code, stream=json.dumps(jobj))
</span><span class="cx">         self.headers.setHeader(&quot;content-type&quot;, http_headers.MimeType(&quot;application&quot;, &quot;json&quot;))
</span></span></pre></div>
<a id="CalendarServerbranchesuserscdaboocrosspodsharingtwistedpluginscaldavpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/cross-pod-sharing/twisted/plugins/caldav.py (12040 => 12041)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/cross-pod-sharing/twisted/plugins/caldav.py        2013-12-06 20:40:44 UTC (rev 12040)
+++ CalendarServer/branches/users/cdaboo/cross-pod-sharing/twisted/plugins/caldav.py        2013-12-06 21:43:35 UTC (rev 12041)
</span><span class="lines">@@ -25,7 +25,6 @@
</span><span class="cx"> from twisted.internet.protocol import Factory
</span><span class="cx"> Factory.noisy = False
</span><span class="cx"> 
</span><del>-
</del><span class="cx"> def serviceMakerProperty(propname):
</span><span class="cx">     def getProperty(self):
</span><span class="cx">         return getattr(reflect.namedClass(self.serviceMakerClass), propname)
</span></span></pre></div>
<a id="CalendarServerbranchesuserscdaboocrosspodsharingtwistedcaldavstdconfigpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/cross-pod-sharing/twistedcaldav/stdconfig.py (12040 => 12041)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/cross-pod-sharing/twistedcaldav/stdconfig.py        2013-12-06 20:40:44 UTC (rev 12040)
+++ CalendarServer/branches/users/cdaboo/cross-pod-sharing/twistedcaldav/stdconfig.py        2013-12-06 21:43:35 UTC (rev 12041)
</span><span class="lines">@@ -317,6 +317,13 @@
</span><span class="cx">                                     # upgrade.
</span><span class="cx"> 
</span><span class="cx">     #
</span><ins>+    # Work queue configuration information
+    #
+    &quot;WorkQueue&quot; : {
+        &quot;ampPort&quot;: 7654,            # Port used for hosts in a cluster to take to each other
+    },
+
+    #
</ins><span class="cx">     # Types of service provided
</span><span class="cx">     #
</span><span class="cx">     &quot;EnableCalDAV&quot;  : True, # Enable CalDAV service
</span><span class="lines">@@ -360,7 +367,7 @@
</span><span class="cx">     #
</span><span class="cx">     # Directory service
</span><span class="cx">     #
</span><del>-    #    A directory service provides information about principals (eg.
</del><ins>+    #    A directory service provides information about principals (e.g.
</ins><span class="cx">     #    users, groups, locations and resources) to the server.
</span><span class="cx">     #
</span><span class="cx">     &quot;DirectoryService&quot;: {
</span><span class="lines">@@ -821,8 +828,9 @@
</span><span class="cx">     &quot;Servers&quot; : {
</span><span class="cx">         &quot;Enabled&quot;: False,                   # Multiple servers enabled or not
</span><span class="cx">         &quot;ConfigFile&quot;: &quot;localservers.xml&quot;,   # File path for server information
</span><del>-        &quot;MaxClients&quot;: 5,                    # Pool size for connections to between servers
</del><ins>+        &quot;MaxClients&quot;: 5,                    # Pool size for connections between servers
</ins><span class="cx">         &quot;InboxName&quot;: &quot;podding&quot;,             # Name for top-level inbox resource
</span><ins>+        &quot;ConduitName&quot;: &quot;conduit&quot;,           # Name for top-level cross-pod resource
</ins><span class="cx">     },
</span><span class="cx"> 
</span><span class="cx">     #
</span><span class="lines">@@ -1063,8 +1071,11 @@
</span><span class="cx">         def _loadImport(childDict):
</span><span class="cx">             # Look for an import and read that one as the main config and merge the current one into that
</span><span class="cx">             if &quot;ImportConfig&quot; in childDict and childDict.ImportConfig:
</span><del>-                configRoot = os.path.join(childDict.ServerRoot, childDict.ConfigRoot)
-                path = _expandPath(fullServerPath(configRoot, childDict.ImportConfig))
</del><ins>+                if childDict.ImportConfig[0] != &quot;.&quot;:
+                    configRoot = os.path.join(childDict.ServerRoot, childDict.ConfigRoot)
+                    path = _expandPath(fullServerPath(configRoot, childDict.ImportConfig))
+                else:
+                    path = childDict.ImportConfig
</ins><span class="cx">                 if os.path.exists(path):
</span><span class="cx">                     importDict = ConfigDict(self._parseConfigFromFile(path))
</span><span class="cx">                     if importDict:
</span></span></pre></div>
<a id="CalendarServerbranchesuserscdaboocrosspodsharingtxdavbasedatastoresubpostgrespy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/base/datastore/subpostgres.py (12040 => 12041)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/base/datastore/subpostgres.py        2013-12-06 20:40:44 UTC (rev 12040)
+++ CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/base/datastore/subpostgres.py        2013-12-06 21:43:35 UTC (rev 12041)
</span><span class="lines">@@ -228,7 +228,7 @@
</span><span class="cx">                 # in /tmp and based on a hash of the data store directory
</span><span class="cx">                 digest = md5(dataStoreDirectory.path).hexdigest()
</span><span class="cx">                 socketDir = &quot;/tmp/ccs_postgres_&quot; + digest
</span><del>-                
</del><ins>+
</ins><span class="cx">             self.socketDir = CachingFilePath(socketDir)
</span><span class="cx">             self.host = self.socketDir.path
</span><span class="cx">             self.port = None
</span></span></pre></div>
<a id="CalendarServerbranchesuserscdaboocrosspodsharingtxdavbasedatastoreutilpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/base/datastore/util.py (12040 => 12041)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/base/datastore/util.py        2013-12-06 20:40:44 UTC (rev 12040)
+++ CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/base/datastore/util.py        2013-12-06 21:43:35 UTC (rev 12041)
</span><span class="lines">@@ -98,6 +98,12 @@
</span><span class="cx">         return &quot;objectWithResourceID:%s:%s&quot; % (homeResourceID, resourceID)
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+    # Home child objects by external id
+
+    def keyForObjectWithExternalID(self, homeResourceID, externalID):
+        return &quot;objectWithExternalID:%s:%s&quot; % (homeResourceID, externalID)
+
+
</ins><span class="cx">     # Home metadata (Created/Modified)
</span><span class="cx"> 
</span><span class="cx">     def keyForHomeMetaData(self, homeResourceID):
</span></span></pre></div>
<a id="CalendarServerbranchesuserscdaboocrosspodsharingtxdavcaldavdatastoreschedulingischedulelocalserverspy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/caldav/datastore/scheduling/ischedule/localservers.py (12040 => 12041)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/caldav/datastore/scheduling/ischedule/localservers.py        2013-12-06 20:40:44 UTC (rev 12040)
+++ CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/caldav/datastore/scheduling/ischedule/localservers.py        2013-12-06 21:43:35 UTC (rev 12041)
</span><span class="lines">@@ -84,6 +84,12 @@
</span><span class="cx">         self._thisServer = None
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+    def addServer(self, server):
+        self._servers[server.id] = server
+        if server.thisServer:
+            self._thisServer = server
+
+
</ins><span class="cx">     def getServerById(self, id):
</span><span class="cx">         return self._servers.get(id)
</span><span class="cx"> 
</span><span class="lines">@@ -125,16 +131,22 @@
</span><span class="cx">     Represents a server.
</span><span class="cx">     &quot;&quot;&quot;
</span><span class="cx"> 
</span><del>-    def __init__(self):
-        self.id = None
-        self.uri = None
-        self.thisServer = False
</del><ins>+    def __init__(self, id=None, uri=None, sharedSecret=None, thisServer=False):
+        self.id = id
+        self.uri = uri
+        self.thisServer = thisServer
</ins><span class="cx">         self.ips = set()
</span><span class="cx">         self.allowed_from_ips = set()
</span><del>-        self.shared_secret = None
</del><ins>+        self.shared_secret = sharedSecret
</ins><span class="cx">         self.isImplicit = True
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+    def details(self):
+        if not hasattr(self, &quot;ssl&quot;):
+            self._parseDetails()
+        return (self.ssl, self.host, self.port, self.path,)
+
+
</ins><span class="cx">     def check(self, ignoreIPLookupFailures=False):
</span><span class="cx">         # Check whether this matches the current server
</span><span class="cx">         parsed_uri = urlparse.urlparse(self.uri)
</span><span class="lines">@@ -215,7 +227,28 @@
</span><span class="cx">         return (SERVER_SECRET_HEADER, self.shared_secret,)
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+    def _parseDetails(self):
+        # Extract scheme, host, port and path
+        if self.uri.startswith(&quot;http://&quot;):
+            self.ssl = False
+            rest = self.uri[7:]
+        elif self.uri.startswith(&quot;https://&quot;):
+            self.ssl = True
+            rest = self.uri[8:]
</ins><span class="cx"> 
</span><ins>+        splits = rest.split(&quot;/&quot;, 1)
+        hostport = splits[0].split(&quot;:&quot;)
+        self.host = hostport[0]
+        if len(hostport) &gt; 1:
+            self.port = int(hostport[1])
+        else:
+            self.port = {False: 80, True: 443}[self.ssl]
+        self.path = &quot;/&quot;
+        if len(splits) &gt; 1:
+            self.path += splits[1]
+
+
+
</ins><span class="cx"> ELEMENT_SERVERS = &quot;servers&quot;
</span><span class="cx"> ELEMENT_SERVER = &quot;server&quot;
</span><span class="cx"> ELEMENT_ID = &quot;id&quot;
</span></span></pre></div>
<a id="CalendarServerbranchesuserscdaboocrosspodsharingtxdavcaldavdatastoresqlpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/caldav/datastore/sql.py (12040 => 12041)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/caldav/datastore/sql.py        2013-12-06 20:40:44 UTC (rev 12040)
+++ CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/caldav/datastore/sql.py        2013-12-06 21:43:35 UTC (rev 12041)
</span><span class="lines">@@ -75,7 +75,7 @@
</span><span class="cx">     InvalidAttachmentOperation, DuplicatePrivateCommentsError
</span><span class="cx"> from txdav.caldav.icalendarstore import QuotaExceeded
</span><span class="cx"> from txdav.common.datastore.sql import CommonHome, CommonHomeChild, \
</span><del>-    CommonObjectResource, ECALENDARTYPE
</del><ins>+    CommonObjectResource, ECALENDARTYPE, CommonHomeExternal
</ins><span class="cx"> from txdav.common.datastore.sql_legacy import PostgresLegacyIndexEmulator, \
</span><span class="cx">     PostgresLegacyInboxIndexEmulator
</span><span class="cx"> from txdav.common.datastore.sql_tables import _ATTACHMENTS_MODE_NONE, \
</span><span class="lines">@@ -433,6 +433,7 @@
</span><span class="cx"> 
</span><span class="cx">     def __init__(self, transaction, ownerUID):
</span><span class="cx"> 
</span><ins>+        self._externalClass = CalendarHomeExternal
</ins><span class="cx">         self._childClass = Calendar
</span><span class="cx">         super(CalendarHome, self).__init__(transaction, ownerUID)
</span><span class="cx"> 
</span><span class="lines">@@ -940,6 +941,127 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+class CalendarHomeExternal(CommonHomeExternal, CalendarHome):
+
+    def __init__(self, transaction, ownerUID, resourceID):
+
+        CalendarHome.__init__(self, transaction, ownerUID)
+        CommonHomeExternal.__init__(self, transaction, ownerUID, resourceID)
+
+
+    def hasCalendarResourceUIDSomewhereElse(self, uid, ok_object, mode):
+        &quot;&quot;&quot;
+        No children.
+        &quot;&quot;&quot;
+        raise AssertionError(&quot;CommonHomeExternal: not supported&quot;)
+
+
+    def getCalendarResourcesForUID(self, uid):
+        &quot;&quot;&quot;
+        No children.
+        &quot;&quot;&quot;
+        raise AssertionError(&quot;CommonHomeExternal: not supported&quot;)
+
+
+    def calendarObjectWithDropboxID(self, dropboxID):
+        &quot;&quot;&quot;
+        No children.
+        &quot;&quot;&quot;
+        raise AssertionError(&quot;CommonHomeExternal: not supported&quot;)
+
+
+    def getAllDropboxIDs(self):
+        &quot;&quot;&quot;
+        No children.
+        &quot;&quot;&quot;
+        raise AssertionError(&quot;CommonHomeExternal: not supported&quot;)
+
+
+    def getAllAttachmentNames(self):
+        &quot;&quot;&quot;
+        No children.
+        &quot;&quot;&quot;
+        raise AssertionError(&quot;CommonHomeExternal: not supported&quot;)
+
+
+    def getAllManagedIDs(self):
+        &quot;&quot;&quot;
+        No children.
+        &quot;&quot;&quot;
+        raise AssertionError(&quot;CommonHomeExternal: not supported&quot;)
+
+
+    def createdHome(self):
+        &quot;&quot;&quot;
+        No children - make this a no-op.
+        &quot;&quot;&quot;
+        return succeed(None)
+
+
+    def splitCalendars(self):
+        &quot;&quot;&quot;
+        No children.
+        &quot;&quot;&quot;
+        raise AssertionError(&quot;CommonHomeExternal: not supported&quot;)
+
+
+    def ensureDefaultCalendarsExist(self):
+        &quot;&quot;&quot;
+        No children.
+        &quot;&quot;&quot;
+        raise AssertionError(&quot;CommonHomeExternal: not supported&quot;)
+
+
+    def setDefaultCalendar(self, calendar, componentType):
+        &quot;&quot;&quot;
+        No children.
+        &quot;&quot;&quot;
+        raise AssertionError(&quot;CommonHomeExternal: not supported&quot;)
+
+
+    def defaultCalendar(self, componentType, create=True):
+        &quot;&quot;&quot;
+        No children.
+        &quot;&quot;&quot;
+        raise AssertionError(&quot;CommonHomeExternal: not supported&quot;)
+
+
+    def isDefaultCalendar(self, calendar):
+        &quot;&quot;&quot;
+        No children.
+        &quot;&quot;&quot;
+        raise AssertionError(&quot;CommonHomeExternal: not supported&quot;)
+
+
+    def getDefaultAlarm(self, vevent, timed):
+        &quot;&quot;&quot;
+        No children.
+        &quot;&quot;&quot;
+        raise AssertionError(&quot;CommonHomeExternal: not supported&quot;)
+
+
+    def setDefaultAlarm(self, alarm, vevent, timed):
+        &quot;&quot;&quot;
+        No children.
+        &quot;&quot;&quot;
+        raise AssertionError(&quot;CommonHomeExternal: not supported&quot;)
+
+
+    def getAvailability(self):
+        &quot;&quot;&quot;
+        No children.
+        &quot;&quot;&quot;
+        raise AssertionError(&quot;CommonHomeExternal: not supported&quot;)
+
+
+    def setAvailability(self, availability):
+        &quot;&quot;&quot;
+        No children.
+        &quot;&quot;&quot;
+        raise AssertionError(&quot;CommonHomeExternal: not supported&quot;)
+
+
+
</ins><span class="cx"> class Calendar(CommonHomeChild):
</span><span class="cx">     &quot;&quot;&quot;
</span><span class="cx">     SQL-based implementation of L{ICalendar}.
</span></span></pre></div>
<a id="CalendarServerbranchesuserscdaboocrosspodsharingtxdavcaldavicalendardirectoryservicepy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/caldav/icalendardirectoryservice.py (12040 => 12041)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/caldav/icalendardirectoryservice.py        2013-12-06 20:40:44 UTC (rev 12040)
+++ CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/caldav/icalendardirectoryservice.py        2013-12-06 21:43:35 UTC (rev 12041)
</span><span class="lines">@@ -60,14 +60,6 @@
</span><span class="cx">         @rtype: C{str}
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx"> 
</span><del>-    def thisServer(): #@NoSelf
-        &quot;&quot;&quot;
-        Indicates whether the record is hosted on this server &quot;pod&quot;.
-
-        @return: C{True} if hosted by this service.
-        @rtype: C{bool}
-        &quot;&quot;&quot;
-
</del><span class="cx">     def calendarsEnabled(): #@NoSelf
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         Indicates whether the record enabled for using the calendar service.
</span></span></pre></div>
<a id="CalendarServerbranchesuserscdaboocrosspodsharingtxdavcarddavdatastoresqlpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/carddav/datastore/sql.py (12040 => 12041)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/carddav/datastore/sql.py        2013-12-06 20:40:44 UTC (rev 12040)
+++ CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/carddav/datastore/sql.py        2013-12-06 21:43:35 UTC (rev 12041)
</span><span class="lines">@@ -430,6 +430,8 @@
</span><span class="cx">     &quot;&quot;&quot;
</span><span class="cx">     implements(IAddressBook)
</span><span class="cx"> 
</span><ins>+    _homeType = EADDRESSBOOKTYPE
+
</ins><span class="cx">     # structured tables.  (new, preferred)
</span><span class="cx">     _homeSchema = schema.ADDRESSBOOK_HOME
</span><span class="cx">     _bindSchema = schema.SHARED_ADDRESSBOOK_BIND
</span><span class="lines">@@ -705,7 +707,7 @@
</span><span class="cx">             home._txn, homeID=home._resourceID
</span><span class="cx">         )
</span><span class="cx">         for groupRow in groupRows:
</span><del>-            bindMode, homeID, resourceID, bindName, bindStatus, bindRevision, bindMessage = groupRow[:AddressBookObject.bindColumnCount] #@UnusedVariable
</del><ins>+            bindMode, homeID, resourceID, externalID, bindName, bindStatus, bindRevision, bindMessage = groupRow[:AddressBookObject.bindColumnCount] #@UnusedVariable
</ins><span class="cx">             ownerAddressBookID = yield AddressBookObject.ownerAddressBookIDFromGroupID(home._txn, resourceID)
</span><span class="cx">             ownerHome = yield home._txn.homeWithResourceID(home._homeType, ownerAddressBookID, create=True)
</span><span class="cx">             names |= set([ownerHome.uid()])
</span><span class="lines">@@ -733,7 +735,7 @@
</span><span class="cx">         )
</span><span class="cx">         # get ownerHomeIDs
</span><span class="cx">         for dataRow in dataRows:
</span><del>-            bindMode, homeID, resourceID, bindName, bindStatus, bindRevision, bindMessage = dataRow[:cls.bindColumnCount] #@UnusedVariable
</del><ins>+            bindMode, homeID, resourceID, externalID, bindName, bindStatus, bindRevision, bindMessage = dataRow[:cls.bindColumnCount] #@UnusedVariable
</ins><span class="cx">             ownerHome = yield home.ownerHomeWithChildID(resourceID)
</span><span class="cx">             ownerHomeToDataRowMap[ownerHome] = dataRow
</span><span class="cx"> 
</span><span class="lines">@@ -742,7 +744,7 @@
</span><span class="cx">             home._txn, homeID=home._resourceID
</span><span class="cx">         )
</span><span class="cx">         for groupBindRow in groupBindRows:
</span><del>-            bindMode, homeID, resourceID, name, bindStatus, bindRevision, bindMessage = groupBindRow[:AddressBookObject.bindColumnCount] #@UnusedVariable
</del><ins>+            bindMode, homeID, resourceID, externalID, name, bindStatus, bindRevision, bindMessage = groupBindRow[:AddressBookObject.bindColumnCount] #@UnusedVariable
</ins><span class="cx">             ownerAddressBookID = yield AddressBookObject.ownerAddressBookIDFromGroupID(home._txn, resourceID)
</span><span class="cx">             ownerHome = yield home.ownerHomeWithChildID(ownerAddressBookID)
</span><span class="cx">             if ownerHome not in ownerHomeToDataRowMap:
</span><span class="lines">@@ -765,7 +767,7 @@
</span><span class="cx"> 
</span><span class="cx">             # Create the actual objects merging in properties
</span><span class="cx">             for ownerHome, dataRow in ownerHomeToDataRowMap.iteritems():
</span><del>-                bindMode, homeID, resourceID, name, bindStatus, bindRevision, bindMessage = dataRow[:cls.bindColumnCount] #@UnusedVariable
</del><ins>+                bindMode, homeID, resourceID, externalID, name, bindStatus, bindRevision, bindMessage = dataRow[:cls.bindColumnCount] #@UnusedVariable
</ins><span class="cx">                 additionalBind = dataRow[cls.bindColumnCount:cls.bindColumnCount + len(cls.additionalBindColumns())]
</span><span class="cx">                 metadata = dataRow[cls.bindColumnCount + len(cls.additionalBindColumns()):]
</span><span class="cx"> 
</span><span class="lines">@@ -888,7 +890,7 @@
</span><span class="cx">         overallBindStatus = _BIND_STATUS_INVITED
</span><span class="cx">         minBindRevision = None
</span><span class="cx">         for row in rows:
</span><del>-            bindMode, homeID, resourceGroupID, name, bindStatus, bindRevision, bindMessage = row[:cls.bindColumnCount] #@UnusedVariable
</del><ins>+            bindMode, homeID, resourceGroupID, externalID, name, bindStatus, bindRevision, bindMessage = row[:cls.bindColumnCount] #@UnusedVariable
</ins><span class="cx">             if groupID is None:
</span><span class="cx">                 groupID = resourceGroupID
</span><span class="cx">             minBindRevision = min(minBindRevision, bindRevision) if minBindRevision is not None else bindRevision
</span><span class="lines">@@ -995,7 +997,7 @@
</span><span class="cx">             readWriteGroupIDs = []
</span><span class="cx">             readOnlyGroupIDs = []
</span><span class="cx">             for groupBindRow in groupBindRows:
</span><del>-                bindMode, homeID, resourceID, name, bindStatus, bindRevision, bindMessage = groupBindRow[:AddressBookObject.bindColumnCount] #@UnusedVariable
</del><ins>+                bindMode, homeID, resourceID, externalID, name, bindStatus, bindRevision, bindMessage = groupBindRow[:AddressBookObject.bindColumnCount] #@UnusedVariable
</ins><span class="cx">                 if bindMode == _BIND_MODE_WRITE:
</span><span class="cx">                     readWriteGroupIDs.append(resourceID)
</span><span class="cx">                 else:
</span><span class="lines">@@ -1056,7 +1058,7 @@
</span><span class="cx">         readWriteGroupIDs = []
</span><span class="cx">         readOnlyGroupIDs = []
</span><span class="cx">         for groupBindRow in groupBindRows:
</span><del>-            bindMode, homeID, resourceID, name, bindStatus, bindRevision, bindMessage = groupBindRow[:AddressBookObject.bindColumnCount] #@UnusedVariable
</del><ins>+            bindMode, homeID, resourceID, externalID, name, bindStatus, bindRevision, bindMessage = groupBindRow[:AddressBookObject.bindColumnCount] #@UnusedVariable
</ins><span class="cx">             if bindMode == _BIND_MODE_WRITE:
</span><span class="cx">                 readWriteGroupIDs.append(resourceID)
</span><span class="cx">             else:
</span><span class="lines">@@ -1594,7 +1596,7 @@
</span><span class="cx">         )
</span><span class="cx">         if groupBindRows:
</span><span class="cx">             groupBindRow = groupBindRows[0]
</span><del>-            bindMode, homeID, resourceID, bindName, bindStatus, bindRevision, bindMessage = groupBindRow[:AddressBookObject.bindColumnCount] #@UnusedVariable
</del><ins>+            bindMode, homeID, resourceID, externalID, bindName, bindStatus, bindRevision, bindMessage = groupBindRow[:AddressBookObject.bindColumnCount] #@UnusedVariable
</ins><span class="cx"> 
</span><span class="cx">             if accepted is not None and (bindStatus == _BIND_STATUS_ACCEPTED) != bool(accepted):
</span><span class="cx">                 returnValue(None)
</span><span class="lines">@@ -1677,7 +1679,7 @@
</span><span class="cx"> 
</span><span class="cx">                 if groupBindRows:
</span><span class="cx">                     groupBindRow = groupBindRows[0]
</span><del>-                    bindMode, homeID, resourceID, bindName, bindStatus, bindRevision, bindMessage = groupBindRow[:AddressBookObject.bindColumnCount] #@UnusedVariable
</del><ins>+                    bindMode, homeID, resourceID, externalID, bindName, bindStatus, bindRevision, bindMessage = groupBindRow[:AddressBookObject.bindColumnCount] #@UnusedVariable
</ins><span class="cx">                     self._bindMode = bindMode
</span><span class="cx">                     self._bindStatus = bindStatus
</span><span class="cx">                     self._bindMessage = bindMessage
</span></span></pre></div>
<a id="CalendarServerbranchesuserscdaboocrosspodsharingtxdavcommondatastorepodding__init__py"></a>
<div class="addfile"><h4>Added: CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/podding/__init__.py (0 => 12041)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/podding/__init__.py                                (rev 0)
+++ CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/podding/__init__.py        2013-12-06 21:43:35 UTC (rev 12041)
</span><span class="lines">@@ -0,0 +1,15 @@
</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.
+##
</ins></span></pre></div>
<a id="CalendarServerbranchesuserscdaboocrosspodsharingtxdavcommondatastorepoddingconduitpy"></a>
<div class="addfile"><h4>Added: CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/podding/conduit.py (0 => 12041)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/podding/conduit.py                                (rev 0)
+++ CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/podding/conduit.py        2013-12-06 21:43:35 UTC (rev 12041)
</span><span class="lines">@@ -0,0 +1,341 @@
</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 twisted.internet.defer import inlineCallbacks, returnValue
+
+from txdav.common.datastore.podding.request import ConduitRequest
+from txdav.common.idirectoryservice import DirectoryRecordNotFoundError
+from txdav.common.icommondatastore import ExternalShareFailed
+
+
+__all__ = [
+    &quot;PoddingConduitResource&quot;,
+]
+
+class BadMessageError(Exception):
+    pass
+
+
+
+class InvalidCrossPodRequestError(Exception):
+    pass
+
+
+
+class FailedCrossPodRequestError(Exception):
+    pass
+
+
+
+class PoddingConduit(object):
+    &quot;&quot;&quot;
+    This class is the API/RPC bridge between cross-pod requests and the store.
+
+    Each cross-pod request/response is described by a Python C{dict} that is serialized
+    to JSON for the HTTP request/response.
+
+    Each request C{dict} has an &quot;action&quot; key that indicates what call is being made, and
+    the other keys are arguments to that call.
+
+    Each response C{dict} has a &quot;result&quot; key that indicates the call result, and other
+    optional keys for any parameters returned by the call.
+
+    The conduit provides two methods for each action: one for the sending side and one for
+    the receiving side, called &quot;send_{action}&quot; and &quot;recv_{action}&quot;, respectively, where
+    {action} is the action value.
+
+    The &quot;send_{action}&quot; calls each have a set of arguments specific to the call itself. The
+    code takes care of packing that into a C{dict} and sending to the appropriate pod.
+
+    The &quot;recv_{action}&quot; calls take a single C{dict} argument that is the deserialized JSON
+    data from the incoming request. The return value is a C{dict} with the result.
+
+    Right now this conduit is used for cross-pod sharing operations. In the future we will
+    likely use it for cross-pod migration.
+    &quot;&quot;&quot;
+
+    def __init__(self, store):
+        &quot;&quot;&quot;
+        @param store: the L{CommonDataStore} in use.
+        &quot;&quot;&quot;
+        self.store = store
+
+
+    def validRequst(self, source_guid, destination_guid):
+        &quot;&quot;&quot;
+        Verify that the specified GUIDs are valid for the request and return the
+        matching directory records.
+
+        @param source_guid: GUID for the user on whose behalf the request is being made
+        @type source_guid: C{str}
+        @param destination_guid: GUID for the user to whom the request is being sent
+        @type destination_guid: C{str}
+
+        @return: C{tuple} of L{IStoreDirectoryRecord}
+        &quot;&quot;&quot;
+
+        source = self.store.directoryService().recordWithUID(source_guid)
+        if source is None:
+            raise DirectoryRecordNotFoundError(&quot;Cross-pod source: {}&quot;.format(source_guid))
+        if not source.thisServer():
+            raise InvalidCrossPodRequestError(&quot;Cross-pod source not on this server: {}&quot;.format(source_guid))
+
+        destination = self.store.directoryService().recordWithUID(destination_guid)
+        if destination is None:
+            raise DirectoryRecordNotFoundError(&quot;Cross-pod destination: {}&quot;.format(destination_guid))
+        if destination.thisServer():
+            raise InvalidCrossPodRequestError(&quot;Cross-pod destination on this server: {}&quot;.format(destination_guid))
+
+        return (source, destination,)
+
+
+    @inlineCallbacks
+    def send_shareinvite(self, txn, homeType, ownerUID, ownerID, ownerName, shareeUID, shareUID, bindMode, summary, supported_components):
+        &quot;&quot;&quot;
+        Send a sharing invite cross-pod message.
+
+        @param homeType: Type of home being shared.
+        @type homeType: C{int}
+        @param ownerUID: GUID of the sharer.
+        @type ownerUID: C{str}
+        @param ownerID: resource ID of the sharer calendar
+        @type ownerID: C{int}
+        @param ownerName: owner's name of the sharer calendar
+        @type ownerName: C{str}
+        @param shareeUID: GUID of the sharee
+        @type shareeUID: C{str}
+        @param shareUID: Resource/invite ID for sharee
+        @type shareUID: C{str}
+        @param bindMode: bind mode for the share
+        @type bindMode: C{str}
+        @param summary: sharing message
+        @type summary: C{str}
+        @param supported_components: supproted components, may be C{None}
+        @type supported_components: C{str}
+        &quot;&quot;&quot;
+
+        _ignore_owner, sharee = self.validRequst(ownerUID, shareeUID)
+
+        action = {
+            &quot;action&quot;: &quot;shareinvite&quot;,
+            &quot;type&quot;: homeType,
+            &quot;owner&quot;: ownerUID,
+            &quot;owner_id&quot;: ownerID,
+            &quot;owner_name&quot;: ownerName,
+            &quot;sharee&quot;: shareeUID,
+            &quot;share_id&quot;: shareUID,
+            &quot;mode&quot;: bindMode,
+            &quot;summary&quot;: summary,
+        }
+        if supported_components is not None:
+            action[&quot;supported-components&quot;] = supported_components
+
+        request = ConduitRequest(sharee.server(), action)
+        response = (yield request.doRequest(txn))
+        if response[&quot;result&quot;] != &quot;ok&quot;:
+            raise FailedCrossPodRequestError(response[&quot;description&quot;])
+
+
+    @inlineCallbacks
+    def recv_shareinvite(self, txn, message):
+        &quot;&quot;&quot;
+        Process a sharing invite cross-pod message. Message arguments as per L{send_shareinvite}.
+
+        @param message: message arguments
+        @type message: C{dict}
+        &quot;&quot;&quot;
+
+        if message[&quot;action&quot;] != &quot;shareinvite&quot;:
+            raise BadMessageError(&quot;Wrong action '{}' for recv_shareinvite&quot;.format(message[&quot;action&quot;]))
+
+        # Create a share
+        shareeHome = yield txn.homeWithUID(message[&quot;type&quot;], message[&quot;sharee&quot;], create=True)
+        if shareeHome is None or shareeHome.external():
+            returnValue({
+                &quot;result&quot;: &quot;bad&quot;,
+                &quot;description&quot;: &quot;Invalid sharee UID specified&quot;,
+            })
+
+        try:
+            yield shareeHome.processExternalInvite(
+                message[&quot;owner&quot;],
+                message[&quot;owner_id&quot;],
+                message[&quot;owner_name&quot;],
+                message[&quot;share_id&quot;],
+                message[&quot;mode&quot;],
+                message[&quot;summary&quot;],
+                supported_components=message.get(&quot;supported-components&quot;)
+            )
+        except ExternalShareFailed as e:
+            returnValue({
+                &quot;result&quot;: &quot;bad&quot;,
+                &quot;description&quot;: str(e),
+            })
+
+        returnValue({
+            &quot;result&quot;: &quot;ok&quot;,
+            &quot;description&quot;: &quot;Success&quot;
+        })
+
+
+    @inlineCallbacks
+    def send_shareuninvite(self, txn, homeType, ownerUID, ownerID, shareeUID, shareUID):
+        &quot;&quot;&quot;
+        Send a sharing uninvite cross-pod message.
+
+        @param homeType: Type of home being shared.
+        @type homeType: C{int}
+        @param ownerUID: GUID of the sharer.
+        @type ownerUID: C{str}
+        @param ownerID: resource ID of the sharer calendar
+        @type ownerID: C{int}
+        @param shareeUID: GUID of the sharee
+        @type shareeUID: C{str}
+        @param shareUID: Resource/invite ID for sharee
+        @type shareUID: C{str}
+        &quot;&quot;&quot;
+
+        _ignore_owner, sharee = self.validRequst(ownerUID, shareeUID)
+
+        action = {
+            &quot;action&quot;: &quot;shareuninvite&quot;,
+            &quot;type&quot;: homeType,
+            &quot;owner&quot;: ownerUID,
+            &quot;owner_id&quot;: ownerID,
+            &quot;sharee&quot;: shareeUID,
+            &quot;share_id&quot;: shareUID,
+        }
+
+        request = ConduitRequest(sharee.server(), action)
+        response = (yield request.doRequest(txn))
+        if response[&quot;result&quot;] != &quot;ok&quot;:
+            raise FailedCrossPodRequestError(response[&quot;description&quot;])
+
+
+    @inlineCallbacks
+    def recv_shareuninvite(self, txn, message):
+        &quot;&quot;&quot;
+        Process a sharing uninvite cross-pod message. Message arguments as per L{send_shareuninvite}.
+
+        @param message: message arguments
+        @type message: C{dict}
+        &quot;&quot;&quot;
+
+        if message[&quot;action&quot;] != &quot;shareuninvite&quot;:
+            raise BadMessageError(&quot;Wrong action '{}' for recv_shareuninvite&quot;.format(message[&quot;action&quot;]))
+
+        # Create a share
+        shareeHome = yield txn.homeWithUID(message[&quot;type&quot;], message[&quot;sharee&quot;], create=True)
+        if shareeHome is None or shareeHome.external():
+            returnValue({
+                &quot;result&quot;: &quot;bad&quot;,
+                &quot;description&quot;: &quot;Invalid sharee UID specified&quot;,
+            })
+
+        try:
+            yield shareeHome.processExternalUninvite(
+                message[&quot;owner&quot;],
+                message[&quot;owner_id&quot;],
+                message[&quot;share_id&quot;],
+            )
+        except ExternalShareFailed as e:
+            returnValue({
+                &quot;result&quot;: &quot;bad&quot;,
+                &quot;description&quot;: str(e),
+            })
+
+        returnValue({
+            &quot;result&quot;: &quot;ok&quot;,
+            &quot;description&quot;: &quot;Success&quot;
+        })
+
+
+    @inlineCallbacks
+    def send_sharereply(self, txn, homeType, ownerUID, shareeUID, shareUID, bindStatus, summary=None):
+        &quot;&quot;&quot;
+        Send a sharing reply cross-pod message.
+
+        @param homeType: Type of home being shared.
+        @type homeType: C{int}
+        @param ownerUID: GUID of the sharer.
+        @type ownerUID: C{str}
+        @param shareeUID: GUID of the sharee
+        @type shareeUID: C{str}
+        @param shareUID: Resource/invite ID for sharee
+        @type shareUID: C{str}
+        @param bindStatus: bind mode for the share
+        @type bindStatus: C{str}
+        @param summary: sharing message
+        @type summary: C{str}
+        &quot;&quot;&quot;
+
+        _ignore_owner, sharee = self.validRequst(shareeUID, ownerUID)
+
+        action = {
+            &quot;action&quot;: &quot;sharereply&quot;,
+            &quot;type&quot;: homeType,
+            &quot;owner&quot;: ownerUID,
+            &quot;sharee&quot;: shareeUID,
+            &quot;share_id&quot;: shareUID,
+            &quot;status&quot;: bindStatus,
+        }
+        if summary is not None:
+            action[&quot;summary&quot;] = summary
+
+        request = ConduitRequest(sharee.server(), action)
+        response = (yield request.doRequest(txn))
+        if response[&quot;result&quot;] != &quot;ok&quot;:
+            raise FailedCrossPodRequestError(response[&quot;description&quot;])
+
+
+    @inlineCallbacks
+    def recv_sharereply(self, txn, message):
+        &quot;&quot;&quot;
+        Process a sharing reply cross-pod message. Message arguments as per L{send_sharereply}.
+
+        @param message: message arguments
+        @type message: C{dict}
+        &quot;&quot;&quot;
+
+        if message[&quot;action&quot;] != &quot;sharereply&quot;:
+            raise BadMessageError(&quot;Wrong action '{}' for recv_sharereply&quot;.format(message[&quot;action&quot;]))
+
+        # Create a share
+        ownerHome = yield txn.homeWithUID(message[&quot;type&quot;], message[&quot;owner&quot;])
+        if ownerHome is None or ownerHome.external():
+            returnValue({
+                &quot;result&quot;: &quot;bad&quot;,
+                &quot;description&quot;: &quot;Invalid owner UID specified&quot;,
+            })
+
+        try:
+            yield ownerHome.processExternalReply(
+                message[&quot;owner&quot;],
+                message[&quot;sharee&quot;],
+                message[&quot;share_id&quot;],
+                message[&quot;status&quot;],
+                summary=message.get(&quot;summary&quot;)
+            )
+        except ExternalShareFailed as e:
+            returnValue({
+                &quot;result&quot;: &quot;bad&quot;,
+                &quot;description&quot;: str(e),
+            })
+
+        returnValue({
+            &quot;result&quot;: &quot;ok&quot;,
+            &quot;description&quot;: &quot;Success&quot;
+        })
</ins></span></pre></div>
<a id="CalendarServerbranchesuserscdaboocrosspodsharingtxdavcommondatastorepoddingrequestpy"></a>
<div class="addfile"><h4>Added: CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/podding/request.py (0 => 12041)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/podding/request.py                                (rev 0)
+++ CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/podding/request.py        2013-12-06 21:43:35 UTC (rev 12041)
</span><span class="lines">@@ -0,0 +1,175 @@
</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 calendarserver.version import version
+
+from twext.internet.gaiendpoint import GAIEndpoint
+from twext.python.log import Logger
+from twext.web2 import responsecode
+from twext.web2.client.http import HTTPClientProtocol, ClientRequest
+from twext.web2.dav.util import allDataFromStream
+from twext.web2.http_headers import Headers, MimeType
+from twext.web2.stream import MemoryStream
+
+from twisted.internet.defer import inlineCallbacks, returnValue
+from twisted.internet.protocol import Factory
+
+from twistedcaldav.accounting import accountingEnabledForCategory, \
+    emitAccounting
+from twistedcaldav.client.pool import _configuredClientContextFactory
+from twistedcaldav.config import config
+from twistedcaldav.util import utf8String
+
+from cStringIO import StringIO
+import json
+
+
+log = Logger()
+
+
+
+class ConduitRequest(object):
+
+    def __init__(self, server, data):
+
+        self.server = server
+        self.data = json.dumps(data)
+
+
+    @inlineCallbacks
+    def doRequest(self, txn):
+
+        # Generate an HTTP client request
+        try:
+            if &quot;xpod&quot; not in txn.logItems:
+                txn.logItems[&quot;xpod&quot;] = 0
+            txn.logItems[&quot;xpod&quot;] += 1
+
+            response = (yield self._processRequest())
+
+            if accountingEnabledForCategory(&quot;xPod&quot;):
+                self.loggedResponse = yield self.logResponse(response)
+                emitAccounting(&quot;xPod&quot;, &quot;&quot;, self.loggedRequest + &quot;\n&quot; + self.loggedResponse, &quot;POST&quot;)
+
+            if response.code in (responsecode.OK,):
+                data = (yield allDataFromStream(response.stream))
+                data = json.loads(data)
+            else:
+                raise ValueError(&quot;Incorrect cross-pod response status code: {}&quot;.format(response.code))
+
+        except Exception as e:
+            # Request failed
+            log.error(&quot;Could not do cross-pod request : {request} {ex}&quot;, request=self, ex=e)
+            raise ValueError(&quot;Failed cross-pod request: {}&quot;.format(response.code))
+
+        returnValue(data)
+
+
+    @inlineCallbacks
+    def logRequest(self, request):
+        &quot;&quot;&quot;
+        Log an HTTP request.
+        &quot;&quot;&quot;
+
+        iostr = StringIO()
+        iostr.write(&quot;&gt;&gt;&gt;&gt; Request start\n\n&quot;)
+        if hasattr(request, &quot;clientproto&quot;):
+            protocol = &quot;HTTP/{:d}.{:d}&quot;.format(request.clientproto[0], request.clientproto[1])
+        else:
+            protocol = &quot;HTTP/1.1&quot;
+        iostr.write(&quot;{} {} {}\n&quot;.format(request.method, request.uri, protocol))
+        for name, valuelist in request.headers.getAllRawHeaders():
+            for value in valuelist:
+                # Do not log authorization details
+                if name not in (&quot;Authorization&quot;,):
+                    iostr.write(&quot;{}: {}\n&quot;.format(name, value))
+                else:
+                    iostr.write(&quot;{}: xxxxxxxxx\n&quot;.format(name))
+        iostr.write(&quot;\n&quot;)
+
+        # We need to play a trick with the request stream as we can only read it once. So we
+        # read it, store the value in a MemoryStream, and replace the request's stream with that,
+        # so the data can be read again.
+        data = (yield allDataFromStream(request.stream))
+        iostr.write(data)
+        request.stream = MemoryStream(data if data is not None else &quot;&quot;)
+        request.stream.doStartReading = None
+
+        iostr.write(&quot;\n\n&gt;&gt;&gt;&gt; Request end\n&quot;)
+        returnValue(iostr.getvalue())
+
+
+    @inlineCallbacks
+    def logResponse(self, response):
+        &quot;&quot;&quot;
+        Log an HTTP request.
+        &quot;&quot;&quot;
+        iostr = StringIO()
+        iostr.write(&quot;&gt;&gt;&gt;&gt; Response start\n\n&quot;)
+        code_message = responsecode.RESPONSES.get(response.code, &quot;Unknown Status&quot;)
+        iostr.write(&quot;HTTP/1.1 {:d} {}\n&quot;.format(response.code, code_message))
+        for name, valuelist in response.headers.getAllRawHeaders():
+            for value in valuelist:
+                # Do not log authorization details
+                if name not in (&quot;WWW-Authenticate&quot;,):
+                    iostr.write(&quot;{}: {}\n&quot;.format(name, value))
+                else:
+                    iostr.write(&quot;{}: xxxxxxxxx\n&quot;.format(name))
+        iostr.write(&quot;\n&quot;)
+
+        # We need to play a trick with the response stream to ensure we don't mess it up. So we
+        # read it, store the value in a MemoryStream, and replace the response's stream with that,
+        # so the data can be read again.
+        data = (yield allDataFromStream(response.stream))
+        iostr.write(data)
+        response.stream = MemoryStream(data if data is not None else &quot;&quot;)
+        response.stream.doStartReading = None
+
+        iostr.write(&quot;\n\n&gt;&gt;&gt;&gt; Response end\n&quot;)
+        returnValue(iostr.getvalue())
+
+
+    @inlineCallbacks
+    def _processRequest(self):
+        &quot;&quot;&quot;
+        Process the request by sending it to the relevant server.
+
+        @return: the HTTP response.
+        @rtype: L{Response}
+        &quot;&quot;&quot;
+        ssl, host, port, _ignore_path = self.server.details()
+        path = &quot;/&quot; + config.Servers.ConduitName
+
+        headers = Headers()
+        headers.setHeader(&quot;Host&quot;, utf8String(host + &quot;:{}&quot;.format(port)))
+        headers.setHeader(&quot;Content-Type&quot;, MimeType(&quot;application&quot;, &quot;json&quot;, params={&quot;charset&quot;: &quot;utf-8&quot;, }))
+        headers.setHeader(&quot;User-Agent&quot;, &quot;CalendarServer/{}&quot;.format(version))
+        headers.addRawHeader(*self.server.secretHeader())
+
+        from twisted.internet import reactor
+        f = Factory()
+        f.protocol = HTTPClientProtocol
+        ep = GAIEndpoint(reactor, host, port, _configuredClientContextFactory() if ssl else None)
+        proto = (yield ep.connect(f))
+
+        request = ClientRequest(&quot;POST&quot;, path, headers, self.data)
+
+        if accountingEnabledForCategory(&quot;xPod&quot;):
+            self.loggedRequest = yield self.logRequest(request)
+
+        response = (yield proto.submitRequest(request))
+
+        returnValue(response)
</ins></span></pre></div>
<a id="CalendarServerbranchesuserscdaboocrosspodsharingtxdavcommondatastorepoddingresourcepy"></a>
<div class="addfile"><h4>Added: CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/podding/resource.py (0 => 12041)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/podding/resource.py                                (rev 0)
+++ CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/podding/resource.py        2013-12-06 21:43:35 UTC (rev 12041)
</span><span class="lines">@@ -0,0 +1,195 @@
</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.
+##
+
+import json
+
+from twext.web2 import responsecode
+from twext.web2.dav.noneprops import NonePropertyStore
+from twext.web2.dav.util import allDataFromStream
+from twext.web2.http import Response, HTTPError, StatusResponse, JSONResponse
+from twext.web2.http_headers import MimeType
+
+from twisted.internet.defer import succeed, returnValue, inlineCallbacks
+
+from twistedcaldav.extensions import DAVResource, \
+    DAVResourceWithoutChildrenMixin
+from twistedcaldav.resource import ReadOnlyNoCopyResourceMixIn
+from twistedcaldav.scheduling_store.caldav.resource import \
+    deliverSchedulePrivilegeSet
+
+from txdav.xml import element as davxml
+from txdav.caldav.datastore.scheduling.ischedule.localservers import Servers
+
+__all__ = [
+    &quot;ConduitResource&quot;,
+]
+
+class ConduitResource(ReadOnlyNoCopyResourceMixIn, DAVResourceWithoutChildrenMixin, DAVResource):
+    &quot;&quot;&quot;
+    Podding cross-pod RPC conduit resource.
+
+    Extends L{DAVResource} to provide cross-pod RPC functionality.
+    &quot;&quot;&quot;
+
+    def __init__(self, parent, store):
+        &quot;&quot;&quot;
+        @param parent: the parent resource of this one.
+        &quot;&quot;&quot;
+        assert parent is not None
+
+        DAVResource.__init__(self, principalCollections=parent.principalCollections())
+
+        self.parent = parent
+        self.store = store
+
+
+    def deadProperties(self):
+        if not hasattr(self, &quot;_dead_properties&quot;):
+            self._dead_properties = NonePropertyStore(self)
+        return self._dead_properties
+
+
+    def etag(self):
+        return succeed(None)
+
+
+    def checkPreconditions(self, request):
+        return None
+
+
+    def resourceType(self):
+        return davxml.ResourceType.ischeduleinbox
+
+
+    def contentType(self):
+        return MimeType.fromString(&quot;text/html; charset=utf-8&quot;)
+
+
+    def isCollection(self):
+        return False
+
+
+    def isCalendarCollection(self):
+        return False
+
+
+    def isPseudoCalendarCollection(self):
+        return False
+
+
+    def principalForCalendarUserAddress(self, address):
+        for principalCollection in self.principalCollections():
+            principal = principalCollection.principalForCalendarUserAddress(address)
+            if principal is not None:
+                return principal
+        return None
+
+
+    def render(self, request):
+        output = &quot;&quot;&quot;&lt;html&gt;
+&lt;head&gt;
+&lt;title&gt;Podding Conduit Resource&lt;/title&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;h1&gt;Podding Conduit Resource.&lt;/h1&gt;
+&lt;/body
+&lt;/html&gt;&quot;&quot;&quot;
+
+        response = Response(200, {}, output)
+        response.headers.setHeader(&quot;content-type&quot;, MimeType(&quot;text&quot;, &quot;html&quot;))
+        return response
+
+
+    @inlineCallbacks
+    def http_POST(self, request):
+        &quot;&quot;&quot;
+        The server-to-server POST method.
+        &quot;&quot;&quot;
+
+        # Check shared secret
+        if not Servers.getThisServer().checkSharedSecret(request.headers):
+            self.log.error(&quot;Invalid shared secret header in cross-pod request&quot;)
+            raise HTTPError(StatusResponse(responsecode.FORBIDDEN, &quot;Not authorized to make this request&quot;))
+
+        # Check content first
+        contentType = request.headers.getHeader(&quot;content-type&quot;)
+
+        if &quot;{}/{}&quot;.format(contentType.mediaType, contentType.mediaSubtype) != &quot;application/json&quot;:
+            self.log.error(&quot;MIME type {mime} not allowed in request&quot;, mime=contentType)
+            raise HTTPError(StatusResponse(responsecode.BAD_REQUEST, &quot;MIME type {} not allowed in request&quot;.format(contentType)))
+
+        body = (yield allDataFromStream(request.stream))
+        try:
+            j = json.loads(body)
+        except ValueError as e:
+            self.log.error(&quot;Invalid JSON data in request: {ex}\n{body}&quot;, ex=e, body=body)
+            raise HTTPError(StatusResponse(responsecode.BAD_REQUEST, &quot;Invalid JSON data in request: {}\n{}&quot;.format(e, body)))
+
+        # Must have a dict with an &quot;action&quot; key
+        try:
+            action = j[&quot;action&quot;]
+        except (KeyError, TypeError) as e:
+            self.log.error(&quot;JSON data must have an object as its root with an 'action' attribute: {ex}\n{json}&quot;, ex=e, json=j)
+            raise HTTPError(StatusResponse(responsecode.BAD_REQUEST, &quot;JSON data must have an object as its root with an 'action' attribute: {}\n{}&quot;.format(e, j,)))
+
+        if action == &quot;ping&quot;:
+            result = {&quot;result&quot;: &quot;ok&quot;}
+            response = JSONResponse(responsecode.OK, result)
+            returnValue(response)
+
+        method = &quot;recv_{}&quot;.format(action)
+        if not hasattr(self.store.conduit, method):
+            self.log.error(&quot;Unsupported action: {action}&quot;, action=action)
+            raise HTTPError(StatusResponse(responsecode.BAD_REQUEST, &quot;Unsupported action: {}&quot;.format(action)))
+
+        # Need a transaction to work with
+        txn = self.store.newTransaction(repr(request))
+
+        # Do the POST processing treating this as a non-local schedule
+        try:
+            result = (yield getattr(self.store.conduit, method)(txn, j))
+        except Exception as e:
+            yield txn.abort()
+            self.log.error(&quot;Failed action: {action}, {ex}&quot;, action=action, ex=e)
+            raise HTTPError(StatusResponse(responsecode.INTERNAL_SERVER_ERROR, &quot;Failed action: {}, {}&quot;.format(action, e)))
+
+        yield txn.commit()
+
+        response = JSONResponse(responsecode.OK, result)
+        returnValue(response)
+
+
+    ##
+    # ACL
+    ##
+
+    def supportedPrivileges(self, request):
+        return succeed(deliverSchedulePrivilegeSet)
+
+
+    def defaultAccessControlList(self):
+        privs = (
+            davxml.Privilege(davxml.Read()),
+        )
+
+        return davxml.ACL(
+            # DAV:Read for all principals (includes anonymous)
+            davxml.ACE(
+                davxml.Principal(davxml.All()),
+                davxml.Grant(*privs),
+                davxml.Protected(),
+            ),
+        )
</ins></span></pre></div>
<a id="CalendarServerbranchesuserscdaboocrosspodsharingtxdavcommondatastorepoddingtest__init__py"></a>
<div class="addfile"><h4>Added: CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/podding/test/__init__.py (0 => 12041)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/podding/test/__init__.py                                (rev 0)
+++ CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/podding/test/__init__.py        2013-12-06 21:43:35 UTC (rev 12041)
</span><span class="lines">@@ -0,0 +1,15 @@
</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.
+##
</ins></span></pre></div>
<a id="CalendarServerbranchesuserscdaboocrosspodsharingtxdavcommondatastorepoddingtesttest_conduitpy"></a>
<div class="addfile"><h4>Added: CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/podding/test/test_conduit.py (0 => 12041)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/podding/test/test_conduit.py                                (rev 0)
+++ CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/podding/test/test_conduit.py        2013-12-06 21:43:35 UTC (rev 12041)
</span><span class="lines">@@ -0,0 +1,116 @@
</span><ins>+##
+# Copyright (c) 2005-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.python.clsprop import classproperty
+import twext.web2.dav.test.util
+from twisted.internet.defer import inlineCallbacks, succeed
+from txdav.caldav.datastore.scheduling.ischedule.localservers import Servers, Server
+from txdav.caldav.datastore.test.util import buildCalendarStore, \
+    TestCalendarStoreDirectoryRecord
+from txdav.common.datastore.podding.resource import ConduitResource
+from txdav.common.datastore.test.util import populateCalendarsFrom, CommonCommonTests
+from txdav.common.datastore.podding.conduit import PoddingConduit, \
+    InvalidCrossPodRequestError
+from txdav.common.idirectoryservice import DirectoryRecordNotFoundError
+
+class Conduit (CommonCommonTests, twext.web2.dav.test.util.TestCase):
+
+    class FakeConduit(object):
+
+        def recv_fake(self, j):
+            return succeed({
+                &quot;result&quot;: &quot;ok&quot;,
+                &quot;back2u&quot;: j[&quot;echo&quot;],
+                &quot;more&quot;: &quot;bits&quot;,
+            })
+
+
+    @inlineCallbacks
+    def setUp(self):
+        yield super(Conduit, self).setUp()
+        self._sqlCalendarStore = yield buildCalendarStore(self, self.notifierFactory)
+        self.directory = self._sqlCalendarStore.directoryService()
+
+        for ctr in range(1, 100):
+            self.directory.addRecord(TestCalendarStoreDirectoryRecord(
+                &quot;puser{:02d}&quot;.format(ctr),
+                (&quot;puser{:02d}&quot;.format(ctr),),
+                &quot;Puser {:02d}&quot;.format(ctr),
+                frozenset((
+                    &quot;urn:uuid:puser{:02d}&quot;.format(ctr),
+                    &quot;mailto:puser{:02d}@example.com&quot;.format(ctr),
+                )),
+                thisServer=False,
+            ))
+
+        self.site.resource.putChild(&quot;conduit&quot;, ConduitResource(self.site.resource, self.storeUnderTest()))
+
+        self.thisServer = Server(&quot;A&quot;, &quot;http://127.0.0.1&quot;, &quot;A&quot;, True)
+        Servers.addServer(self.thisServer)
+
+        yield self.populate()
+
+
+    def storeUnderTest(self):
+        &quot;&quot;&quot;
+        Return a store for testing.
+        &quot;&quot;&quot;
+        return self._sqlCalendarStore
+
+
+    @inlineCallbacks
+    def populate(self):
+        yield populateCalendarsFrom(self.requirements, self.storeUnderTest())
+        self.notifierFactory.reset()
+
+
+    @classproperty(cache=False)
+    def requirements(cls): #@NoSelf
+        return {
+        &quot;user01&quot;: {
+            &quot;calendar_1&quot;: {
+            },
+            &quot;inbox&quot;: {
+            },
+        },
+        &quot;user02&quot;: {
+            &quot;calendar_1&quot;: {
+            },
+            &quot;inbox&quot;: {
+            },
+        },
+        &quot;user03&quot;: {
+            &quot;calendar_1&quot;: {
+            },
+            &quot;inbox&quot;: {
+            },
+        },
+    }
+
+
+    def test_validRequst(self):
+        &quot;&quot;&quot;
+        Cross-pod request fails when there is no shared secret header present.
+        &quot;&quot;&quot;
+
+        conduit = PoddingConduit(self.storeUnderTest())
+        r1, r2 = conduit.validRequst(&quot;user01&quot;, &quot;puser02&quot;)
+        self.assertTrue(r1 is not None)
+        self.assertTrue(r2 is not None)
+
+        self.assertRaises(DirectoryRecordNotFoundError, conduit.validRequst, &quot;bogus01&quot;, &quot;user02&quot;)
+        self.assertRaises(DirectoryRecordNotFoundError, conduit.validRequst, &quot;user01&quot;, &quot;bogus02&quot;)
+        self.assertRaises(InvalidCrossPodRequestError, conduit.validRequst, &quot;user01&quot;, &quot;user02&quot;)
</ins></span></pre></div>
<a id="CalendarServerbranchesuserscdaboocrosspodsharingtxdavcommondatastorepoddingtesttest_external_homepy"></a>
<div class="addfile"><h4>Added: CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/podding/test/test_external_home.py (0 => 12041)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/podding/test/test_external_home.py                                (rev 0)
+++ CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/podding/test/test_external_home.py        2013-12-06 21:43:35 UTC (rev 12041)
</span><span class="lines">@@ -0,0 +1,98 @@
</span><ins>+##
+# Copyright (c) 2005-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 txdav.caldav.datastore.scheduling.ischedule.localservers import Servers, \
+    Server
+from txdav.caldav.datastore.test.util import buildCalendarStore, \
+    TestCalendarStoreDirectoryRecord
+from txdav.common.datastore.podding.resource import ConduitResource
+from txdav.common.datastore.sql_tables import _HOME_STATUS_NORMAL, \
+    _HOME_STATUS_EXTERNAL
+from txdav.common.datastore.test.util import CommonCommonTests
+from txdav.common.idirectoryservice import DirectoryRecordNotFoundError
+
+import twext.web2.dav.test.util
+
+
+class ExternalHome(CommonCommonTests, twext.web2.dav.test.util.TestCase):
+
+    @inlineCallbacks
+    def setUp(self):
+        yield super(ExternalHome, self).setUp()
+        self._sqlCalendarStore = yield buildCalendarStore(self, self.notifierFactory)
+        self.directory = self._sqlCalendarStore.directoryService()
+
+        for ctr in range(1, 100):
+            self.directory.addRecord(TestCalendarStoreDirectoryRecord(
+                &quot;puser{:02d}&quot;.format(ctr),
+                (&quot;puser{:02d}&quot;.format(ctr),),
+                &quot;Puser {:02d}&quot;.format(ctr),
+                frozenset((
+                    &quot;urn:uuid:puser{:02d}&quot;.format(ctr),
+                    &quot;mailto:puser{:02d}@example.com&quot;.format(ctr),
+                )),
+                thisServer=False,
+            ))
+
+        self.site.resource.putChild(&quot;conduit&quot;, ConduitResource(self.site.resource, self.storeUnderTest()))
+
+        self.thisServer = Server(&quot;A&quot;, &quot;http://127.0.0.1&quot;, &quot;A&quot;, True)
+        Servers.addServer(self.thisServer)
+
+
+    def storeUnderTest(self):
+        &quot;&quot;&quot;
+        Return a store for testing.
+        &quot;&quot;&quot;
+        return self._sqlCalendarStore
+
+
+    @inlineCallbacks
+    def test_validNormalHome(self):
+        &quot;&quot;&quot;
+        Locally hosted homes are valid.
+        &quot;&quot;&quot;
+
+        for i in range(1, 100):
+            home = yield self.transactionUnderTest().calendarHomeWithUID(&quot;user{:02d}&quot;.format(i), create=True)
+            self.assertTrue(home is not None)
+            self.assertEqual(home._status, _HOME_STATUS_NORMAL)
+            calendar = yield home.childWithName(&quot;calendar&quot;)
+            self.assertTrue(calendar is not None)
+
+
+    @inlineCallbacks
+    def test_validExternalHome(self):
+        &quot;&quot;&quot;
+        Externally hosted homes are valid.
+        &quot;&quot;&quot;
+
+        for i in range(1, 100):
+            home = yield self.transactionUnderTest().calendarHomeWithUID(&quot;puser{:02d}&quot;.format(i), create=True)
+            self.assertTrue(home is not None)
+            self.assertEqual(home._status, _HOME_STATUS_EXTERNAL)
+            self.assertRaises(AssertionError, home.childWithName, &quot;calendar&quot;)
+
+
+    @inlineCallbacks
+    def test_invalidHome(self):
+        &quot;&quot;&quot;
+        Homes are invalid.
+        &quot;&quot;&quot;
+
+        yield self.assertFailure(self.transactionUnderTest().calendarHomeWithUID(&quot;buser01&quot;, create=True), DirectoryRecordNotFoundError)
</ins></span></pre></div>
<a id="CalendarServerbranchesuserscdaboocrosspodsharingtxdavcommondatastorepoddingtesttest_resourcepy"></a>
<div class="addfile"><h4>Added: CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/podding/test/test_resource.py (0 => 12041)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/podding/test/test_resource.py                                (rev 0)
+++ CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/podding/test/test_resource.py        2013-12-06 21:43:35 UTC (rev 12041)
</span><span class="lines">@@ -0,0 +1,272 @@
</span><ins>+##
+# Copyright (c) 2005-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.python.clsprop import classproperty
+from twext.web2 import http_headers, responsecode
+import twext.web2.dav.test.util
+from twext.web2.dav.util import allDataFromStream
+from twext.web2.test.test_server import SimpleRequest
+from twisted.internet.defer import inlineCallbacks, succeed
+from txdav.caldav.datastore.scheduling.ischedule.localservers import Servers, Server
+from txdav.caldav.datastore.test.util import buildCalendarStore
+from txdav.common.datastore.podding.resource import ConduitResource
+from txdav.common.datastore.test.util import populateCalendarsFrom, CommonCommonTests
+import json
+
+class ConduitPOST (CommonCommonTests, twext.web2.dav.test.util.TestCase):
+
+    class FakeConduit(object):
+
+        def recv_fake(self, j):
+            return succeed({
+                &quot;result&quot;: &quot;ok&quot;,
+                &quot;back2u&quot;: j[&quot;echo&quot;],
+                &quot;more&quot;: &quot;bits&quot;,
+            })
+
+
+    @inlineCallbacks
+    def setUp(self):
+        yield super(ConduitPOST, self).setUp()
+        self._sqlCalendarStore = yield buildCalendarStore(self, self.notifierFactory)
+        self.directory = self._sqlCalendarStore.directoryService()
+
+        self.site.resource.putChild(&quot;conduit&quot;, ConduitResource(self.site.resource, self.storeUnderTest()))
+
+        self.thisServer = Server(&quot;A&quot;, &quot;http://127.0.0.1&quot;, &quot;A&quot;, True)
+        Servers.addServer(self.thisServer)
+
+        yield self.populate()
+
+
+    def storeUnderTest(self):
+        &quot;&quot;&quot;
+        Return a store for testing.
+        &quot;&quot;&quot;
+        return self._sqlCalendarStore
+
+
+    @inlineCallbacks
+    def populate(self):
+        yield populateCalendarsFrom(self.requirements, self.storeUnderTest())
+        self.notifierFactory.reset()
+
+
+    @classproperty(cache=False)
+    def requirements(cls): #@NoSelf
+        return {
+        &quot;user01&quot;: {
+            &quot;calendar_1&quot;: {
+            },
+            &quot;inbox&quot;: {
+            },
+        },
+        &quot;user02&quot;: {
+            &quot;calendar_1&quot;: {
+            },
+            &quot;inbox&quot;: {
+            },
+        },
+        &quot;user03&quot;: {
+            &quot;calendar_1&quot;: {
+            },
+            &quot;inbox&quot;: {
+            },
+        },
+    }
+
+
+    @inlineCallbacks
+    def test_receive_no_secret(self):
+        &quot;&quot;&quot;
+        Cross-pod request fails when there is no shared secret header present.
+        &quot;&quot;&quot;
+
+        request = SimpleRequest(
+            self.site,
+            &quot;POST&quot;,
+            &quot;/conduit&quot;,
+            headers=http_headers.Headers(rawHeaders={
+                &quot;Content-Type&quot;: (&quot;text/plain&quot;,)
+            }),
+            content=&quot;&quot;&quot;Hello, World!
+&quot;&quot;&quot;.replace(&quot;\n&quot;, &quot;\r\n&quot;)
+        )
+
+        response = (yield self.send(request))
+        self.assertEqual(response.code, responsecode.FORBIDDEN)
+
+
+    @inlineCallbacks
+    def test_receive_wrong_mime(self):
+        &quot;&quot;&quot;
+        Cross-pod request fails when Content-Type header is wrong.
+        &quot;&quot;&quot;
+
+        request = SimpleRequest(
+            self.site,
+            &quot;POST&quot;,
+            &quot;/conduit&quot;,
+            headers=http_headers.Headers(rawHeaders={
+                &quot;Content-Type&quot;: (&quot;text/plain&quot;,),
+                self.thisServer.secretHeader()[0]: self.thisServer.secretHeader()[1],
+            }),
+            content=&quot;&quot;&quot;Hello, World!
+&quot;&quot;&quot;.replace(&quot;\n&quot;, &quot;\r\n&quot;)
+        )
+
+        response = (yield self.send(request))
+        self.assertEqual(response.code, responsecode.BAD_REQUEST)
+
+
+    @inlineCallbacks
+    def test_receive_invalid_json(self):
+        &quot;&quot;&quot;
+        Cross-pod request fails when request data is not JSON.
+        &quot;&quot;&quot;
+
+        request = SimpleRequest(
+            self.site,
+            &quot;POST&quot;,
+            &quot;/conduit&quot;,
+            headers=http_headers.Headers(rawHeaders={
+                &quot;Content-Type&quot;: (&quot;application/json&quot;,),
+                self.thisServer.secretHeader()[0]: self.thisServer.secretHeader()[1],
+            }),
+            content=&quot;&quot;&quot;Hello, World!
+&quot;&quot;&quot;.replace(&quot;\n&quot;, &quot;\r\n&quot;)
+        )
+
+        response = (yield self.send(request))
+        self.assertEqual(response.code, responsecode.BAD_REQUEST)
+
+
+    @inlineCallbacks
+    def test_receive_bad_json(self):
+        &quot;&quot;&quot;
+        Cross-pod request fails when JSON data does not have an &quot;action&quot;.
+        &quot;&quot;&quot;
+
+        request = SimpleRequest(
+            self.site,
+            &quot;POST&quot;,
+            &quot;/conduit&quot;,
+            headers=http_headers.Headers(rawHeaders={
+                &quot;Content-Type&quot;: (&quot;application/json&quot;,),
+                self.thisServer.secretHeader()[0]: self.thisServer.secretHeader()[1],
+            }),
+            content=&quot;&quot;&quot;
+{
+    &quot;foo&quot;:&quot;bar&quot;
+}
+&quot;&quot;&quot;.replace(&quot;\n&quot;, &quot;\r\n&quot;)
+        )
+
+        response = (yield self.send(request))
+        self.assertEqual(response.code, responsecode.BAD_REQUEST)
+
+
+    @inlineCallbacks
+    def test_receive_ping(self):
+        &quot;&quot;&quot;
+        Cross-pod request works with the &quot;ping&quot; action.
+        &quot;&quot;&quot;
+
+        request = SimpleRequest(
+            self.site,
+            &quot;POST&quot;,
+            &quot;/conduit&quot;,
+            headers=http_headers.Headers(rawHeaders={
+                &quot;Content-Type&quot;: (&quot;application/json&quot;,),
+                self.thisServer.secretHeader()[0]: self.thisServer.secretHeader()[1],
+            }),
+            content=&quot;&quot;&quot;
+{
+    &quot;action&quot;:&quot;ping&quot;
+}
+&quot;&quot;&quot;.replace(&quot;\n&quot;, &quot;\r\n&quot;)
+        )
+
+        response = (yield self.send(request))
+        self.assertEqual(response.code, responsecode.OK)
+        data = (yield allDataFromStream(response.stream))
+        j = json.loads(data)
+        self.assertTrue(&quot;result&quot; in j)
+        self.assertEqual(j[&quot;result&quot;], &quot;ok&quot;)
+
+
+    @inlineCallbacks
+    def test_receive_fake_conduit_no_action(self):
+        &quot;&quot;&quot;
+        Cross-pod request fails when conduit does not support the action.
+        &quot;&quot;&quot;
+
+        self.patch(self.storeUnderTest(), &quot;conduit&quot;, self.FakeConduit())
+
+        request = SimpleRequest(
+            self.site,
+            &quot;POST&quot;,
+            &quot;/conduit&quot;,
+            headers=http_headers.Headers(rawHeaders={
+                &quot;Content-Type&quot;: (&quot;application/json&quot;,),
+                self.thisServer.secretHeader()[0]: self.thisServer.secretHeader()[1],
+            }),
+            content=&quot;&quot;&quot;
+{
+    &quot;action&quot;:&quot;bogus&quot;,
+    &quot;echo&quot;:&quot;bravo&quot;
+}
+&quot;&quot;&quot;.replace(&quot;\n&quot;, &quot;\r\n&quot;)
+        )
+
+        response = (yield self.send(request))
+        self.assertEqual(response.code, responsecode.BAD_REQUEST)
+
+
+    @inlineCallbacks
+    def test_receive_fake_conduit(self):
+        &quot;&quot;&quot;
+        Cross-pod request works when conduit does support the action.
+        &quot;&quot;&quot;
+
+        self.patch(self.storeUnderTest(), &quot;conduit&quot;, self.FakeConduit())
+
+        request = SimpleRequest(
+            self.site,
+            &quot;POST&quot;,
+            &quot;/conduit&quot;,
+            headers=http_headers.Headers(rawHeaders={
+                &quot;Content-Type&quot;: (&quot;application/json&quot;,),
+                self.thisServer.secretHeader()[0]: self.thisServer.secretHeader()[1],
+            }),
+            content=&quot;&quot;&quot;
+{
+    &quot;action&quot;:&quot;fake&quot;,
+    &quot;echo&quot;:&quot;bravo&quot;
+}
+&quot;&quot;&quot;.replace(&quot;\n&quot;, &quot;\r\n&quot;)
+        )
+
+        response = (yield self.send(request))
+        self.assertEqual(response.code, responsecode.OK)
+        data = (yield allDataFromStream(response.stream))
+        j = json.loads(data)
+        self.assertTrue(&quot;result&quot; in j)
+        self.assertEqual(j[&quot;result&quot;], &quot;ok&quot;)
+        self.assertTrue(&quot;back2u&quot; in j)
+        self.assertEqual(j[&quot;back2u&quot;], &quot;bravo&quot;)
+        self.assertTrue(&quot;more&quot; in j)
+        self.assertEqual(j[&quot;more&quot;], &quot;bits&quot;)
</ins></span></pre></div>
<a id="CalendarServerbranchesuserscdaboocrosspodsharingtxdavcommondatastoresqlpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/sql.py (12040 => 12041)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/sql.py        2013-12-06 20:40:44 UTC (rev 12040)
+++ CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/sql.py        2013-12-06 21:43:35 UTC (rev 12041)
</span><span class="lines">@@ -14,9 +14,6 @@
</span><span class="cx"> # See the License for the specific language governing permissions and
</span><span class="cx"> # limitations under the License.
</span><span class="cx"> ##
</span><del>-from collections import namedtuple
-from txdav.xml import element
-from txdav.base.propertystore.base import PropertyName
</del><span class="cx"> 
</span><span class="cx"> &quot;&quot;&quot;
</span><span class="cx"> SQL data store.
</span><span class="lines">@@ -57,31 +54,37 @@
</span><span class="cx"> 
</span><span class="cx"> from txdav.base.datastore.util import QueryCacher
</span><span class="cx"> from txdav.base.datastore.util import normalizeUUIDOrNot
</span><ins>+from txdav.base.propertystore.base import PropertyName
</ins><span class="cx"> from txdav.base.propertystore.none import PropertyStore as NonePropertyStore
</span><span class="cx"> from txdav.base.propertystore.sql import PropertyStore
</span><span class="cx"> from txdav.caldav.icalendarstore import ICalendarTransaction, ICalendarStore
</span><span class="cx"> from txdav.carddav.iaddressbookstore import IAddressBookTransaction
</span><span class="cx"> from txdav.common.datastore.common import HomeChildBase
</span><ins>+from txdav.common.datastore.podding.conduit import PoddingConduit
</ins><span class="cx"> from txdav.common.datastore.sql_tables import _BIND_MODE_OWN, \
</span><span class="cx">     _BIND_STATUS_ACCEPTED, _BIND_STATUS_DECLINED, _BIND_STATUS_INVALID, \
</span><span class="cx">     _BIND_STATUS_INVITED, _BIND_MODE_DIRECT, _BIND_STATUS_DELETED, \
</span><del>-    _BIND_MODE_INDIRECT
</del><ins>+    _BIND_MODE_INDIRECT, _HOME_STATUS_NORMAL, _HOME_STATUS_EXTERNAL
</ins><span class="cx"> from txdav.common.datastore.sql_tables import schema, splitSQLString
</span><del>-from txdav.common.icommondatastore import ConcurrentModification
</del><ins>+from txdav.common.icommondatastore import ConcurrentModification, \
+    RecordNotAllowedError, ExternalShareFailed
</ins><span class="cx"> from txdav.common.icommondatastore import HomeChildNameNotAllowedError, \
</span><span class="cx">     HomeChildNameAlreadyExistsError, NoSuchHomeChildError, \
</span><span class="cx">     ObjectResourceNameNotAllowedError, ObjectResourceNameAlreadyExistsError, \
</span><span class="cx">     NoSuchObjectResourceError, AllRetriesFailed, InvalidSubscriptionValues, \
</span><span class="cx">     InvalidIMIPTokenValues, TooManyObjectResourcesError
</span><del>-from txdav.common.idirectoryservice import IStoreDirectoryService
</del><ins>+from txdav.common.idirectoryservice import IStoreDirectoryService, \
+    DirectoryRecordNotFoundError
</ins><span class="cx"> from txdav.common.inotifications import INotificationCollection, \
</span><span class="cx">     INotificationObject
</span><span class="cx"> from txdav.idav import ChangeCategory
</span><ins>+from txdav.xml import element
</ins><span class="cx"> 
</span><span class="cx"> from uuid import uuid4, UUID
</span><span class="cx"> 
</span><span class="cx"> from zope.interface import implements, directlyProvides
</span><span class="cx"> 
</span><ins>+from collections import namedtuple
</ins><span class="cx"> import json
</span><span class="cx"> import sys
</span><span class="cx"> import time
</span><span class="lines">@@ -188,6 +191,8 @@
</span><span class="cx">         else:
</span><span class="cx">             self.queryCacher = None
</span><span class="cx"> 
</span><ins>+        self.conduit = PoddingConduit(self)
+
</ins><span class="cx">         # Always import these here to trigger proper &quot;registration&quot; of the calendar and address book
</span><span class="cx">         # home classes
</span><span class="cx">         __import__(&quot;txdav.caldav.datastore.sql&quot;)
</span><span class="lines">@@ -1469,7 +1474,77 @@
</span><span class="cx">         returnValue(shareeView)
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+    #
+    # External (cross-pod) sharing - entry point is the sharee's home collection.
+    #
+    @inlineCallbacks
+    def processExternalInvite(self, ownerUID, ownerRID, ownerName, shareUID, bindMode, summary, supported_components=None):
+        &quot;&quot;&quot;
+        External invite received.
+        &quot;&quot;&quot;
</ins><span class="cx"> 
</span><ins>+        # Get the owner home - create external one if not present
+        ownerHome = yield self._txn.homeWithUID(self._homeType, ownerUID, create=True)
+        if ownerHome is None or not ownerHome.external():
+            raise ExternalShareFailed(&quot;Invalid owner UID: {}&quot;.format(ownerUID))
+
+        # Try to find owner calendar via its external id
+        ownerView = yield ownerHome.childWithExternalID(ownerRID)
+        if ownerView is None:
+            ownerView = yield ownerHome.createChildWithName(ownerName, externalID=ownerRID)
+            if supported_components is not None and hasattr(ownerView, &quot;setSupportedComponents&quot;):
+                yield ownerView.setSupportedComponents(supported_components)
+
+        # Now carry out the share operation
+        yield ownerView.inviteUserToShare(self.uid(), bindMode, summary, shareName=shareUID)
+
+
+    @inlineCallbacks
+    def processExternalUninvite(self, ownerUID, ownerRID, shareUID):
+        &quot;&quot;&quot;
+        External invite received.
+        &quot;&quot;&quot;
+
+        # Get the owner home
+        ownerHome = yield self._txn.homeWithUID(self._homeType, ownerUID)
+        if ownerHome is None or not ownerHome.external():
+            raise ExternalShareFailed(&quot;Invalid owner UID: {}&quot;.format(ownerUID))
+
+        # Try to find owner calendar via its external id
+        ownerView = yield ownerHome.childWithExternalID(ownerRID)
+        if ownerView is None:
+            raise ExternalShareFailed(&quot;Invalid share ID: {}&quot;.format(shareUID))
+
+        # Now carry out the share operation
+        yield ownerView.uninviteUserFromShare(self.uid())
+
+
+    @inlineCallbacks
+    def processExternalReply(self, ownerUID, shareeUID, shareUID, bindStatus, summary=None):
+        &quot;&quot;&quot;
+        External invite received.
+        &quot;&quot;&quot;
+
+        # Make sure the shareeUID and shareUID match
+
+        # Get the owner home - create external one if not present
+        shareeHome = yield self._txn.homeWithUID(self._homeType, shareeUID)
+        if shareeHome is None or not shareeHome.external():
+            raise ExternalShareFailed(&quot;Invalid sharee UID: {}&quot;.format(shareeUID))
+
+        # Try to find owner calendar via its external id
+        shareeView = yield shareeHome.anyObjectWithShareUID(shareUID)
+        if shareeView is None:
+            raise ExternalShareFailed(&quot;Invalid share UID: {}&quot;.format(shareUID))
+
+        # Now carry out the share operation
+        if bindStatus == _BIND_STATUS_ACCEPTED:
+            yield shareeHome.acceptShare(shareUID, summary)
+        elif bindStatus == _BIND_STATUS_DECLINED:
+            yield shareeHome.declineShare(shareUID)
+
+
+
</ins><span class="cx"> class CommonHome(SharingHomeMixIn):
</span><span class="cx">     log = Logger()
</span><span class="cx"> 
</span><span class="lines">@@ -1477,6 +1552,7 @@
</span><span class="cx">     _homeType = None
</span><span class="cx">     _homeTable = None
</span><span class="cx">     _homeMetaDataTable = None
</span><ins>+    _externalClass = None
</ins><span class="cx">     _childClass = None
</span><span class="cx">     _childTable = None
</span><span class="cx">     _notifierPrefix = None
</span><span class="lines">@@ -1490,6 +1566,7 @@
</span><span class="cx">         self._txn = transaction
</span><span class="cx">         self._ownerUID = ownerUID
</span><span class="cx">         self._resourceID = None
</span><ins>+        self._status = _HOME_STATUS_NORMAL
</ins><span class="cx">         self._dataVersion = None
</span><span class="cx">         self._childrenLoaded = False
</span><span class="cx">         self._children = {}
</span><span class="lines">@@ -1553,6 +1630,7 @@
</span><span class="cx">         return (
</span><span class="cx">             cls._homeSchema.RESOURCE_ID,
</span><span class="cx">             cls._homeSchema.OWNER_UID,
</span><ins>+            cls._homeSchema.STATUS,
</ins><span class="cx">         )
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -1567,6 +1645,7 @@
</span><span class="cx">         return (
</span><span class="cx">             &quot;_resourceID&quot;,
</span><span class="cx">             &quot;_ownerUID&quot;,
</span><ins>+            &quot;_status&quot;,
</ins><span class="cx">         )
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -1611,39 +1690,53 @@
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         result = yield self._cacher.get(self._ownerUID)
</span><span class="cx">         if result is None:
</span><del>-            result = yield self._homeColumnsFromOwnerQuery.on(
-                self._txn, ownerUID=self._ownerUID)
-            if result and not no_cache:
-                yield self._cacher.set(self._ownerUID, result)
</del><ins>+            result = yield self._homeColumnsFromOwnerQuery.on(self._txn, ownerUID=self._ownerUID)
+            if result:
+                result = result[0]
+                if not no_cache:
+                    yield self._cacher.set(self._ownerUID, result)
</ins><span class="cx"> 
</span><span class="cx">         if result:
</span><del>-            for attr, value in zip(self.homeAttributes(), result[0]):
</del><ins>+            for attr, value in zip(self.homeAttributes(), result):
</ins><span class="cx">                 setattr(self, attr, value)
</span><span class="cx"> 
</span><del>-            queryCacher = self._txn._queryCacher
-            if queryCacher:
-                # Get cached copy
-                cacheKey = queryCacher.keyForHomeMetaData(self._resourceID)
-                data = yield queryCacher.get(cacheKey)
</del><ins>+            # STOP! If the status is external we need to convert this object to a CommonHomeExternal class which will
+            # have the right behavior for non-hosted external users.
+            if self._status == _HOME_STATUS_EXTERNAL:
+                actualHome = self._externalClass(self._txn, self._ownerUID, self._resourceID)
</ins><span class="cx">             else:
</span><del>-                data = None
-            if data is None:
-                # Don't have a cached copy
-                data = (yield self._metaDataQuery.on(
-                    self._txn, resourceID=self._resourceID))[0]
-                if queryCacher:
-                    # Cache the data
-                    yield queryCacher.setAfterCommit(self._txn, cacheKey, data)
</del><ins>+                actualHome = self
+            yield actualHome.initMetaDataFromStore()
+            yield actualHome._loadPropertyStore()
+            returnValue(actualHome)
+        else:
+            returnValue(None)
</ins><span class="cx"> 
</span><del>-            for attr, value in zip(self.metadataAttributes(), data):
-                setattr(self, attr, value)
</del><span class="cx"> 
</span><del>-            yield self._loadPropertyStore()
-            returnValue(self)
</del><ins>+    @inlineCallbacks
+    def initMetaDataFromStore(self):
+        &quot;&quot;&quot;
+        Load up the metadata and property store
+        &quot;&quot;&quot;
+
+        queryCacher = self._txn._queryCacher
+        if queryCacher:
+            # Get cached copy
+            cacheKey = queryCacher.keyForHomeMetaData(self._resourceID)
+            data = yield queryCacher.get(cacheKey)
</ins><span class="cx">         else:
</span><del>-            returnValue(None)
</del><ins>+            data = None
+        if data is None:
+            # Don't have a cached copy
+            data = (yield self._metaDataQuery.on(self._txn, resourceID=self._resourceID))[0]
+            if queryCacher:
+                # Cache the data
+                yield queryCacher.setAfterCommit(self._txn, cacheKey, data)
</ins><span class="cx"> 
</span><ins>+        for attr, value in zip(self.metadataAttributes(), data):
+            setattr(self, attr, value)
</ins><span class="cx"> 
</span><ins>+
</ins><span class="cx">     @classmethod
</span><span class="cx">     @inlineCallbacks
</span><span class="cx">     def listHomes(cls, txn):
</span><span class="lines">@@ -1673,6 +1766,13 @@
</span><span class="cx">             if not create:
</span><span class="cx">                 returnValue(None)
</span><span class="cx"> 
</span><ins>+            # Determine if the user is local or external
+            record = txn.directoryService().recordWithUID(uid)
+            if record is None:
+                raise DirectoryRecordNotFoundError(&quot;Cannot create home for UID since no directory record exists: {uid}&quot;.format(uid=uid))
+
+            state = _HOME_STATUS_NORMAL if record.thisServer() else _HOME_STATUS_EXTERNAL
+
</ins><span class="cx">             # Use savepoint so we can do a partial rollback if there is a race condition
</span><span class="cx">             # where this row has already been inserted
</span><span class="cx">             savepoint = SavepointAction(&quot;homeWithUID&quot;)
</span><span class="lines">@@ -1684,11 +1784,12 @@
</span><span class="cx">                 resourceid = (yield Insert(
</span><span class="cx">                     {
</span><span class="cx">                         cls._homeSchema.OWNER_UID: uid,
</span><ins>+                        cls._homeSchema.STATUS: state,
</ins><span class="cx">                         cls._homeSchema.DATAVERSION: cls._dataVersionValue,
</span><span class="cx">                     },
</span><del>-                    Return=cls._homeSchema.RESOURCE_ID).on(txn))[0][0]
-                yield Insert(
-                    {cls._homeMetaDataSchema.RESOURCE_ID: resourceid}).on(txn)
</del><ins>+                    Return=cls._homeSchema.RESOURCE_ID
+                ).on(txn))[0][0]
+                yield Insert({cls._homeMetaDataSchema.RESOURCE_ID: resourceid}).on(txn)
</ins><span class="cx">             except Exception:  # FIXME: Really want to trap the pg.DatabaseError but in a non-DB specific manner
</span><span class="cx">                 yield savepoint.rollback(txn)
</span><span class="cx"> 
</span><span class="lines">@@ -1726,7 +1827,7 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     def __repr__(self):
</span><del>-        return &quot;&lt;%s: %s&gt;&quot; % (self.__class__.__name__, self._resourceID)
</del><ins>+        return &quot;&lt;%s: %s, %s&gt;&quot; % (self.__class__.__name__, self._resourceID, self._ownerUID)
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     def id(self):
</span><span class="lines">@@ -1748,6 +1849,15 @@
</span><span class="cx">         return self._ownerUID
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+    def external(self):
+        &quot;&quot;&quot;
+        Is this an external home.
+
+        @return: a string.
+        &quot;&quot;&quot;
+        return False
+
+
</ins><span class="cx">     def transaction(self):
</span><span class="cx">         return self._txn
</span><span class="cx"> 
</span><span class="lines">@@ -1865,6 +1975,17 @@
</span><span class="cx">         return self._childClass.objectWithID(self, resourceID)
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+    def childWithExternalID(self, externalID):
+        &quot;&quot;&quot;
+        Retrieve the child with the given C{externalID} contained in this
+        home.
+
+        @param name: a string.
+        @return: an L{ICalendar} or C{None} if no such child exists.
+        &quot;&quot;&quot;
+        return self._childClass.objectWithExternalID(self, externalID)
+
+
</ins><span class="cx">     def allChildWithID(self, resourceID):
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         Retrieve the child with the given C{resourceID} contained in this
</span><span class="lines">@@ -1877,12 +1998,11 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><del>-    def createChildWithName(self, name):
</del><ins>+    def createChildWithName(self, name, externalID=None):
</ins><span class="cx">         if name.startswith(&quot;.&quot;):
</span><span class="cx">             raise HomeChildNameNotAllowedError(name)
</span><span class="cx"> 
</span><del>-        yield self._childClass.create(self, name)
-        child = (yield self.childWithName(name))
</del><ins>+        child = yield self._childClass.create(self, name, externalID=externalID)
</ins><span class="cx">         returnValue(child)
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -2413,6 +2533,165 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+class CommonHomeExternal(CommonHome):
+    &quot;&quot;&quot;
+    A CommonHome for a user not hosted on this system, but on another pod. This is needed to provide a
+    &quot;reference&quot; to the external user so we can share with them. Actual operations to list child resources, etc
+    are all stubbed out since no data for the user is actually hosted in this store.
+    &quot;&quot;&quot;
+
+    def __init__(self, transaction, ownerUID, resourceID):
+        super(CommonHomeExternal, self).__init__(transaction, ownerUID)
+        self._resourceID = resourceID
+        self._status = _HOME_STATUS_EXTERNAL
+
+
+    def initFromStore(self, no_cache=False):
+        &quot;&quot;&quot;
+        Never called - this should be done by CommonHome.initFromStore only.
+        &quot;&quot;&quot;
+        raise AssertionError(&quot;CommonHomeExternal: not supported&quot;)
+
+
+    def external(self):
+        &quot;&quot;&quot;
+        Is this an external home.
+
+        @return: a string.
+        &quot;&quot;&quot;
+        return True
+
+
+    def children(self):
+        &quot;&quot;&quot;
+        No children.
+        &quot;&quot;&quot;
+        raise AssertionError(&quot;CommonHomeExternal: not supported&quot;)
+
+
+    def loadChildren(self):
+        &quot;&quot;&quot;
+        No children.
+        &quot;&quot;&quot;
+        raise AssertionError(&quot;CommonHomeExternal: not supported&quot;)
+
+
+    def listChildren(self):
+        &quot;&quot;&quot;
+        No children.
+        &quot;&quot;&quot;
+        raise AssertionError(&quot;CommonHomeExternal: not supported&quot;)
+
+
+    def objectWithShareUID(self, shareUID):
+        &quot;&quot;&quot;
+        No children.
+        &quot;&quot;&quot;
+        raise AssertionError(&quot;CommonHomeExternal: not supported&quot;)
+
+
+    def invitedObjectWithShareUID(self, shareUID):
+        &quot;&quot;&quot;
+        No children.
+        &quot;&quot;&quot;
+        raise AssertionError(&quot;CommonHomeExternal: not supported&quot;)
+
+
+    @memoizedKey(&quot;name&quot;, &quot;_children&quot;)
+    @inlineCallbacks
+    def createChildWithName(self, name, externalID=None):
+        &quot;&quot;&quot;
+        No real children - only external ones.
+        &quot;&quot;&quot;
+        if externalID is None:
+            raise AssertionError(&quot;CommonHomeExternal: not supported&quot;)
+        child = yield super(CommonHomeExternal, self).createChildWithName(name, externalID)
+        returnValue(child)
+
+
+    def removeChildWithName(self, name):
+        &quot;&quot;&quot;
+        No children.
+        &quot;&quot;&quot;
+        raise AssertionError(&quot;CommonHomeExternal: not supported&quot;)
+
+
+    def syncToken(self):
+        &quot;&quot;&quot;
+        No children.
+        &quot;&quot;&quot;
+        raise AssertionError(&quot;CommonHomeExternal: not supported&quot;)
+
+
+    def resourceNamesSinceRevision(self, revision, depth):
+        &quot;&quot;&quot;
+        No children.
+        &quot;&quot;&quot;
+        raise AssertionError(&quot;CommonHomeExternal: not supported&quot;)
+
+
+    @inlineCallbacks
+    def _loadPropertyStore(self):
+        &quot;&quot;&quot;
+        No property store - stub to a NonePropertyStore.
+        &quot;&quot;&quot;
+        props = yield PropertyStore.load(
+            self.uid(),
+            self.uid(),
+            self._txn,
+            self._resourceID,
+            notifyCallback=self.notifyChanged
+        )
+        self._propertyStore = props
+
+
+    def properties(self):
+        return self._propertyStore
+
+
+    def objectResourcesWithUID(self, uid, ignore_children=[], allowShared=True):
+        &quot;&quot;&quot;
+        No children.
+        &quot;&quot;&quot;
+        raise AssertionError(&quot;CommonHomeExternal: not supported&quot;)
+
+
+    def objectResourceWithID(self, rid):
+        &quot;&quot;&quot;
+        No children.
+        &quot;&quot;&quot;
+        raise AssertionError(&quot;CommonHomeExternal: not supported&quot;)
+
+
+    def notifyChanged(self):
+        &quot;&quot;&quot;
+        Notifications are not handled for external homes - make this a no-op.
+        &quot;&quot;&quot;
+        return succeed(None)
+
+
+    def bumpModified(self):
+        &quot;&quot;&quot;
+        No changes recorded for external homes - make this a no-op.
+        &quot;&quot;&quot;
+        return succeed(None)
+
+
+    def removeUnacceptedShares(self):
+        &quot;&quot;&quot;
+        No children.
+        &quot;&quot;&quot;
+        raise AssertionError(&quot;CommonHomeExternal: not supported&quot;)
+
+
+#    def ownerHomeAndChildNameForChildID(self, resourceID):
+#        &quot;&quot;&quot;
+#        No children.
+#        &quot;&quot;&quot;
+#        raise AssertionError(&quot;CommonHomeExternal: not supported&quot;)
+
+
+
</ins><span class="cx"> class _SharedSyncLogic(object):
</span><span class="cx">     &quot;&quot;&quot;
</span><span class="cx">     Logic for maintaining sync-token shared between notification collections and
</span><span class="lines">@@ -2791,6 +3070,7 @@
</span><span class="cx">         return Insert({
</span><span class="cx">             bind.HOME_RESOURCE_ID: Parameter(&quot;homeID&quot;),
</span><span class="cx">             bind.RESOURCE_ID: Parameter(&quot;resourceID&quot;),
</span><ins>+            bind.EXTERNAL_ID: Parameter(&quot;externalID&quot;),
</ins><span class="cx">             bind.RESOURCE_NAME: Parameter(&quot;name&quot;),
</span><span class="cx">             bind.BIND_MODE: Parameter(&quot;mode&quot;),
</span><span class="cx">             bind.BIND_STATUS: Parameter(&quot;bindStatus&quot;),
</span><span class="lines">@@ -2872,11 +3152,21 @@
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         bind = cls._bindSchema
</span><span class="cx">         return cls._bindFor((bind.RESOURCE_ID == Parameter(&quot;resourceID&quot;))
</span><del>-                               .And(bind.HOME_RESOURCE_ID == Parameter(&quot;homeID&quot;))
-                               )
</del><ins>+                            .And(bind.HOME_RESOURCE_ID == Parameter(&quot;homeID&quot;)))
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @classproperty
</span><ins>+    def _bindForExternalIDAndHomeID(cls): #@NoSelf
+        &quot;&quot;&quot;
+        DAL query that looks up home bind rows by home child
+        resource ID and home resource ID.
+        &quot;&quot;&quot;
+        bind = cls._bindSchema
+        return cls._bindFor((bind.EXTERNAL_ID == Parameter(&quot;externalID&quot;))
+                            .And(bind.HOME_RESOURCE_ID == Parameter(&quot;homeID&quot;)))
+
+
+    @classproperty
</ins><span class="cx">     def _bindForNameAndHomeID(cls): #@NoSelf
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         DAL query that looks up any bind rows by home child
</span><span class="lines">@@ -2884,15 +3174,14 @@
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         bind = cls._bindSchema
</span><span class="cx">         return cls._bindFor((bind.RESOURCE_NAME == Parameter(&quot;name&quot;))
</span><del>-                               .And(bind.HOME_RESOURCE_ID == Parameter(&quot;homeID&quot;))
-                               )
</del><ins>+                            .And(bind.HOME_RESOURCE_ID == Parameter(&quot;homeID&quot;)))
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     #
</span><span class="cx">     # Higher level API
</span><span class="cx">     #
</span><span class="cx">     @inlineCallbacks
</span><del>-    def inviteUserToShare(self, shareeUID, mode, summary):
</del><ins>+    def inviteUserToShare(self, shareeUID, mode, summary, shareName=None):
</ins><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         Invite a user to share this collection - either create the share if it does not exist, or
</span><span class="cx">         update the existing share with new values. Make sure a notification is sent as well.
</span><span class="lines">@@ -2911,15 +3200,19 @@
</span><span class="cx">             status = _BIND_STATUS_INVITED if shareeView.shareStatus() in (_BIND_STATUS_DECLINED, _BIND_STATUS_INVALID) else None
</span><span class="cx">             yield self.updateShare(shareeView, mode=mode, status=status, summary=summary)
</span><span class="cx">         else:
</span><del>-            shareeView = yield self.createShare(shareeUID=shareeUID, mode=mode, summary=summary)
</del><ins>+            shareeView = yield self.createShare(shareeUID=shareeUID, mode=mode, summary=summary, shareName=shareName)
</ins><span class="cx"> 
</span><del>-        # Send invite notification
-        yield self._sendInviteNotification(shareeView)
</del><ins>+        # Check for external
+        if shareeView.viewerHome().external():
+            yield self._sendExternalInvite(shareeView)
+        else:
+            # Send invite notification
+            yield self._sendInviteNotification(shareeView)
</ins><span class="cx">         returnValue(shareeView)
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><del>-    def directShareWithUser(self, shareeUID):
</del><ins>+    def directShareWithUser(self, shareeUID, shareName=None):
</ins><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         Create a direct share with the specified user. Note it is currently up to the app layer
</span><span class="cx">         to enforce access control - this is not ideal as we really should have control of that in
</span><span class="lines">@@ -2934,7 +3227,7 @@
</span><span class="cx">         # Ignore if it already exists
</span><span class="cx">         shareeView = yield self.shareeView(shareeUID)
</span><span class="cx">         if shareeView is None:
</span><del>-            shareeView = yield self.createShare(shareeUID=shareeUID, mode=_BIND_MODE_DIRECT)
</del><ins>+            shareeView = yield self.createShare(shareeUID=shareeUID, mode=_BIND_MODE_DIRECT, shareName=shareName)
</ins><span class="cx">             yield shareeView.newShare()
</span><span class="cx">         returnValue(shareeView)
</span><span class="cx"> 
</span><span class="lines">@@ -2951,13 +3244,16 @@
</span><span class="cx"> 
</span><span class="cx">         shareeView = yield self.shareeView(shareeUID)
</span><span class="cx">         if shareeView is not None:
</span><del>-            # If current user state is accepted then we send an invite with the new state, otherwise
-            # we cancel any existing invites for the user
-            if not shareeView.direct():
-                if shareeView.shareStatus() != _BIND_STATUS_ACCEPTED:
-                    yield self._removeInviteNotification(shareeView)
-                else:
-                    yield self._sendInviteNotification(shareeView, notificationState=_BIND_STATUS_DELETED)
</del><ins>+            if shareeView.viewerHome().external():
+                yield self._sendExternalUninvite(shareeView)
+            else:
+                # If current user state is accepted then we send an invite with the new state, otherwise
+                # we cancel any existing invites for the user
+                if not shareeView.direct():
+                    if shareeView.shareStatus() != _BIND_STATUS_ACCEPTED:
+                        yield self._removeInviteNotification(shareeView)
+                    else:
+                        yield self._sendInviteNotification(shareeView, notificationState=_BIND_STATUS_DELETED)
</ins><span class="cx"> 
</span><span class="cx">             # Remove the bind
</span><span class="cx">             yield self.removeShare(shareeView)
</span><span class="lines">@@ -2970,10 +3266,13 @@
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx"> 
</span><span class="cx">         if not self.direct() and self.shareStatus() != _BIND_STATUS_ACCEPTED:
</span><ins>+            if self.external():
+                yield self._replyExternalInvite(_BIND_STATUS_ACCEPTED, summary)
</ins><span class="cx">             ownerView = yield self.ownerView()
</span><span class="cx">             yield ownerView.updateShare(self, status=_BIND_STATUS_ACCEPTED)
</span><span class="cx">             yield self.newShare(displayname=summary)
</span><del>-            yield self._sendReplyNotification(ownerView, summary)
</del><ins>+            if not ownerView.external():
+                yield self._sendReplyNotification(ownerView, summary)
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><span class="lines">@@ -2983,9 +3282,12 @@
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx"> 
</span><span class="cx">         if not self.direct() and self.shareStatus() != _BIND_STATUS_DECLINED:
</span><ins>+            if self.external():
+                yield self._replyExternalInvite(_BIND_STATUS_DECLINED)
</ins><span class="cx">             ownerView = yield self.ownerView()
</span><span class="cx">             yield ownerView.updateShare(self, status=_BIND_STATUS_DECLINED)
</span><del>-            yield self._sendReplyNotification(ownerView)
</del><ins>+            if not ownerView.external():
+                yield self._sendReplyNotification(ownerView)
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><span class="lines">@@ -3100,10 +3402,56 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     #
</span><del>-    # Lower level API
</del><ins>+    # External/cross-pod API
</ins><span class="cx">     #
</span><ins>+    @inlineCallbacks
+    def _sendExternalInvite(self, shareeView):
</ins><span class="cx"> 
</span><ins>+        yield self._txn.store().conduit.send_shareinvite(
+            self._txn,
+            shareeView.ownerHome()._homeType,
+            shareeView.ownerHome().uid(),
+            self.id(),
+            self.shareName(),
+            shareeView.viewerHome().uid(),
+            shareeView.shareUID(),
+            shareeView.shareMode(),
+            shareeView.shareMessage(),
+            supported_components=self.getSupportedComponents() if hasattr(self, &quot;getSupportedComponents&quot;) else None,
+        )
+
+
</ins><span class="cx">     @inlineCallbacks
</span><ins>+    def _sendExternalUninvite(self, shareeView):
+
+        yield self._txn.store().conduit.send_shareuninvite(
+            self._txn,
+            shareeView.ownerHome()._homeType,
+            shareeView.ownerHome().uid(),
+            self.id(),
+            shareeView.viewerHome().uid(),
+            shareeView.shareUID(),
+        )
+
+
+    @inlineCallbacks
+    def _replyExternalInvite(self, status, summary=None):
+
+        yield self._txn.store().conduit.send_sharereply(
+            self._txn,
+            self.viewerHome()._homeType,
+            self.ownerHome().uid(),
+            self.viewerHome().uid(),
+            self.shareName(),
+            status,
+            summary,
+        )
+
+
+    #
+    # Lower level API
+    #
+    @inlineCallbacks
</ins><span class="cx">     def ownerView(self):
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         Return the owner resource counterpart of this shared resource.
</span><span class="lines">@@ -3126,7 +3474,7 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><del>-    def shareWith(self, shareeHome, mode, status=None, summary=None):
</del><ins>+    def shareWith(self, shareeHome, mode, status=None, summary=None, shareName=None):
</ins><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         Share this (owned) L{CommonHomeChild} with another home.
</span><span class="cx"> 
</span><span class="lines">@@ -3154,11 +3502,12 @@
</span><span class="cx"> 
</span><span class="cx">         @inlineCallbacks
</span><span class="cx">         def doInsert(subt):
</span><del>-            newName = self.newShareName()
</del><ins>+            newName = shareName if shareName is not None else self.newShareName()
</ins><span class="cx">             yield self._bindInsertQuery.on(
</span><span class="cx">                 subt,
</span><span class="cx">                 homeID=shareeHome._resourceID,
</span><span class="cx">                 resourceID=self._resourceID,
</span><ins>+                externalID=None,
</ins><span class="cx">                 name=newName,
</span><span class="cx">                 mode=mode,
</span><span class="cx">                 bindStatus=status,
</span><span class="lines">@@ -3192,7 +3541,7 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><del>-    def createShare(self, shareeUID, mode, summary=None):
</del><ins>+    def createShare(self, shareeUID, mode, summary=None, shareName=None):
</ins><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         Create a new shared resource. If the mode is direct, the share is created in accepted state,
</span><span class="cx">         otherwise the share is created in invited state.
</span><span class="lines">@@ -3204,6 +3553,7 @@
</span><span class="cx">             mode=mode,
</span><span class="cx">             status=_BIND_STATUS_INVITED if mode != _BIND_MODE_DIRECT else _BIND_STATUS_ACCEPTED,
</span><span class="cx">             summary=summary,
</span><ins>+            shareName=shareName,
</ins><span class="cx">         )
</span><span class="cx">         shareeView = yield self.shareeView(shareeUID)
</span><span class="cx">         returnValue(shareeView)
</span><span class="lines">@@ -3267,12 +3617,7 @@
</span><span class="cx">             if summary is not None:
</span><span class="cx">                 shareeView._bindMessage = columnMap[bind.MESSAGE]
</span><span class="cx"> 
</span><del>-            queryCacher = self._txn._queryCacher
-            if queryCacher:
-                cacheKey = queryCacher.keyForObjectWithName(shareeView._home._resourceID, shareeView._name)
-                yield queryCacher.invalidateAfterCommit(self._txn, cacheKey)
-                cacheKey = queryCacher.keyForObjectWithResourceID(shareeView._home._resourceID, shareeView._resourceID)
-                yield queryCacher.invalidateAfterCommit(self._txn, cacheKey)
</del><ins>+            yield shareeView.invalidateQueryCache()
</ins><span class="cx"> 
</span><span class="cx">             # Must send notification to ensure cache invalidation occurs
</span><span class="cx">             yield self.notifyPropertyChanged()
</span><span class="lines">@@ -3326,12 +3671,7 @@
</span><span class="cx">             homeID=shareeHome._resourceID,
</span><span class="cx">         )
</span><span class="cx"> 
</span><del>-        queryCacher = self._txn._queryCacher
-        if queryCacher:
-            cacheKey = queryCacher.keyForObjectWithName(shareeHome._resourceID, shareeView._name)
-            yield queryCacher.invalidateAfterCommit(self._txn, cacheKey)
-            cacheKey = queryCacher.keyForObjectWithResourceID(shareeHome._resourceID, shareeView._resourceID)
-            yield queryCacher.invalidateAfterCommit(self._txn, cacheKey)
</del><ins>+        yield shareeView.invalidateQueryCache()
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><span class="lines">@@ -3574,13 +3914,14 @@
</span><span class="cx">             cls._bindSchema.BIND_MODE,
</span><span class="cx">             cls._bindSchema.HOME_RESOURCE_ID,
</span><span class="cx">             cls._bindSchema.RESOURCE_ID,
</span><ins>+            cls._bindSchema.EXTERNAL_ID,
</ins><span class="cx">             cls._bindSchema.RESOURCE_NAME,
</span><span class="cx">             cls._bindSchema.BIND_STATUS,
</span><span class="cx">             cls._bindSchema.BIND_REVISION,
</span><span class="cx">             cls._bindSchema.MESSAGE
</span><span class="cx">         )
</span><span class="cx"> 
</span><del>-    bindColumnCount = 7
</del><ins>+    bindColumnCount = 8
</ins><span class="cx"> 
</span><span class="cx">     @classmethod
</span><span class="cx">     def additionalBindColumns(cls):
</span><span class="lines">@@ -3640,6 +3981,7 @@
</span><span class="cx">             yield queryCacher.invalidateAfterCommit(self._txn, queryCacher.keyForHomeChildMetaData(self._resourceID))
</span><span class="cx">             yield queryCacher.invalidateAfterCommit(self._txn, queryCacher.keyForObjectWithName(self._home._resourceID, self._name))
</span><span class="cx">             yield queryCacher.invalidateAfterCommit(self._txn, queryCacher.keyForObjectWithResourceID(self._home._resourceID, self._resourceID))
</span><ins>+            yield queryCacher.invalidateAfterCommit(self._txn, queryCacher.keyForObjectWithExternalID(self._home._resourceID, self._externalID))
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -3665,11 +4007,12 @@
</span><span class="cx">     _objectSchema = None
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-    def __init__(self, home, name, resourceID, mode, status, revision=0, message=None, ownerHome=None, ownerName=None):
</del><ins>+    def __init__(self, home, name, resourceID, mode, status, revision=0, message=None, ownerHome=None, ownerName=None, externalID=None):
</ins><span class="cx"> 
</span><span class="cx">         self._home = home
</span><span class="cx">         self._name = name
</span><span class="cx">         self._resourceID = resourceID
</span><ins>+        self._externalID = externalID
</ins><span class="cx">         self._bindMode = mode
</span><span class="cx">         self._bindStatus = status
</span><span class="cx">         self._bindRevision = revision
</span><span class="lines">@@ -3752,7 +4095,7 @@
</span><span class="cx"> 
</span><span class="cx">         # Create the actual objects merging in properties
</span><span class="cx">         for dataRow in dataRows:
</span><del>-            bindMode, homeID, resourceID, bindName, bindStatus, bindRevision, bindMessage = dataRow[:cls.bindColumnCount] #@UnusedVariable
</del><ins>+            bindMode, homeID, resourceID, externalID, bindName, bindStatus, bindRevision, bindMessage = dataRow[:cls.bindColumnCount] #@UnusedVariable
</ins><span class="cx">             additionalBind = dataRow[cls.bindColumnCount:cls.bindColumnCount + len(cls.additionalBindColumns())]
</span><span class="cx">             metadata = dataRow[cls.bindColumnCount + len(cls.additionalBindColumns()):]
</span><span class="cx"> 
</span><span class="lines">@@ -3773,6 +4116,7 @@
</span><span class="cx">                 message=bindMessage,
</span><span class="cx">                 ownerHome=ownerHome,
</span><span class="cx">                 ownerName=ownerName,
</span><ins>+                externalID=externalID,
</ins><span class="cx">             )
</span><span class="cx">             for attr, value in zip(cls.additionalBindAttributes(), additionalBind):
</span><span class="cx">                 setattr(child, attr, value)
</span><span class="lines">@@ -3800,8 +4144,13 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @classmethod
</span><ins>+    def objectWithExternalID(cls, home, externalID, accepted=True):
+        return cls._objectWithNameOrID(home, externalID=externalID, accepted=accepted)
+
+
+    @classmethod
</ins><span class="cx">     @inlineCallbacks
</span><del>-    def _objectWithNameOrID(cls, home, name=None, resourceID=None, accepted=True):
</del><ins>+    def _objectWithNameOrID(cls, home, name=None, resourceID=None, externalID=None, accepted=True):
</ins><span class="cx">         # replaces objectWithName()
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         Retrieve the child with the given C{name} or C{resourceID} contained in the given
</span><span class="lines">@@ -3821,27 +4170,32 @@
</span><span class="cx">             # Retrieve data from cache
</span><span class="cx">             if name:
</span><span class="cx">                 cacheKey = queryCacher.keyForObjectWithName(home._resourceID, name)
</span><del>-            else:
</del><ins>+            elif resourceID:
</ins><span class="cx">                 cacheKey = queryCacher.keyForObjectWithResourceID(home._resourceID, resourceID)
</span><ins>+            elif externalID:
+                cacheKey = queryCacher.keyForObjectWithExternalID(home._resourceID, externalID)
</ins><span class="cx">             rows = yield queryCacher.get(cacheKey)
</span><span class="cx"> 
</span><span class="cx">         if rows is None:
</span><span class="cx">             # No cached copy
</span><span class="cx">             if name:
</span><span class="cx">                 rows = yield cls._bindForNameAndHomeID.on(home._txn, name=name, homeID=home._resourceID)
</span><del>-            else:
</del><ins>+            elif resourceID:
</ins><span class="cx">                 rows = yield cls._bindForResourceIDAndHomeID.on(home._txn, resourceID=resourceID, homeID=home._resourceID)
</span><ins>+            elif resourceID:
+                rows = yield cls._bindForExternalIDAndHomeID.on(home._txn, externalID=externalID, homeID=home._resourceID)
</ins><span class="cx"> 
</span><span class="cx">         if not rows:
</span><span class="cx">             returnValue(None)
</span><span class="cx"> 
</span><span class="cx">         row = rows[0]
</span><del>-        bindMode, homeID, resourceID, name, bindStatus, bindRevision, bindMessage = row[:cls.bindColumnCount] #@UnusedVariable
</del><ins>+        bindMode, homeID, resourceID, externalID, name, bindStatus, bindRevision, bindMessage = row[:cls.bindColumnCount] #@UnusedVariable
</ins><span class="cx"> 
</span><span class="cx">         if queryCacher:
</span><span class="cx">             # Cache the result
</span><span class="cx">             queryCacher.setAfterCommit(home._txn, queryCacher.keyForObjectWithName(home._resourceID, name), rows)
</span><span class="cx">             queryCacher.setAfterCommit(home._txn, queryCacher.keyForObjectWithResourceID(home._resourceID, resourceID), rows)
</span><ins>+            queryCacher.setAfterCommit(home._txn, queryCacher.keyForObjectWithExternalID(home._resourceID, externalID), rows)
</ins><span class="cx"> 
</span><span class="cx">         if accepted is not None and (bindStatus == _BIND_STATUS_ACCEPTED) != bool(accepted):
</span><span class="cx">             returnValue(None)
</span><span class="lines">@@ -3862,7 +4216,8 @@
</span><span class="cx">             revision=bindRevision,
</span><span class="cx">             message=bindMessage,
</span><span class="cx">             ownerHome=ownerHome,
</span><del>-            ownerName=ownerName
</del><ins>+            ownerName=ownerName,
+            externalID=externalID,
</ins><span class="cx">         )
</span><span class="cx">         yield child.initFromStore(additionalBind)
</span><span class="cx">         returnValue(child)
</span><span class="lines">@@ -3892,35 +4247,28 @@
</span><span class="cx"> 
</span><span class="cx">     @classmethod
</span><span class="cx">     @inlineCallbacks
</span><del>-    def create(cls, home, name):
</del><ins>+    def create(cls, home, name, externalID=None):
</ins><span class="cx"> 
</span><del>-        if (yield cls._bindForNameAndHomeID.on(home._txn,
-            name=name, homeID=home._resourceID)):
</del><ins>+        if (yield cls._bindForNameAndHomeID.on(home._txn, name=name, homeID=home._resourceID)):
</ins><span class="cx">             raise HomeChildNameAlreadyExistsError(name)
</span><span class="cx"> 
</span><span class="cx">         if name.startswith(&quot;.&quot;):
</span><span class="cx">             raise HomeChildNameNotAllowedError(name)
</span><span class="cx"> 
</span><span class="cx">         # Create this object
</span><del>-        resourceID = (
-            yield cls._insertHomeChild.on(home._txn))[0][0]
</del><ins>+        resourceID = (yield cls._insertHomeChild.on(home._txn))[0][0]
</ins><span class="cx"> 
</span><span class="cx">         # Initialize this object
</span><del>-        _created, _modified = (
-            yield cls._insertHomeChildMetaData.on(home._txn,
-                                                  resourceID=resourceID))[0]
</del><ins>+        _created, _modified = (yield cls._insertHomeChildMetaData.on(home._txn, resourceID=resourceID))[0]
</ins><span class="cx">         # Bind table needs entry
</span><span class="cx">         yield cls._bindInsertQuery.on(
</span><del>-            home._txn, homeID=home._resourceID, resourceID=resourceID,
</del><ins>+            home._txn, homeID=home._resourceID, resourceID=resourceID, externalID=externalID,
</ins><span class="cx">             name=name, mode=_BIND_MODE_OWN, bindStatus=_BIND_STATUS_ACCEPTED,
</span><span class="cx">             message=None,
</span><span class="cx">         )
</span><span class="cx"> 
</span><span class="cx">         # Initialize other state
</span><del>-        child = cls(home, name, resourceID, _BIND_MODE_OWN, _BIND_STATUS_ACCEPTED)
-        child._created = _created
-        child._modified = _modified
-        yield child._loadPropertyStore()
</del><ins>+        child = yield cls.objectWithID(home, resourceID)
</ins><span class="cx"> 
</span><span class="cx">         yield child._initSyncToken()
</span><span class="cx"> 
</span><span class="lines">@@ -3981,6 +4329,15 @@
</span><span class="cx">         return self._resourceID
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+    def external(self):
+        &quot;&quot;&quot;
+        Is this an external home.
+
+        @return: a string.
+        &quot;&quot;&quot;
+        return self.ownerHome().external()
+
+
</ins><span class="cx">     @property
</span><span class="cx">     def _txn(self):
</span><span class="cx">         return self._home._txn
</span><span class="lines">@@ -4030,12 +4387,7 @@
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         oldName = self._name
</span><span class="cx"> 
</span><del>-        queryCacher = self._home._txn._queryCacher
-        if queryCacher:
-            cacheKey = queryCacher.keyForObjectWithName(self._home._resourceID, oldName)
-            yield queryCacher.invalidateAfterCommit(self._home._txn, cacheKey)
-            cacheKey = queryCacher.keyForObjectWithResourceID(self._home._resourceID, self._resourceID)
-            yield queryCacher.invalidateAfterCommit(self._home._txn, cacheKey)
</del><ins>+        yield self.invalidateQueryCache()
</ins><span class="cx"> 
</span><span class="cx">         yield self._renameQuery.on(self._txn, name=name,
</span><span class="cx">                                    resourceID=self._resourceID,
</span><span class="lines">@@ -4065,16 +4417,10 @@
</span><span class="cx">         # Do before setting _resourceID making changes
</span><span class="cx">         yield self.notifyPropertyChanged()
</span><span class="cx"> 
</span><del>-        queryCacher = self._home._txn._queryCacher
-        if queryCacher:
-            cacheKey = queryCacher.keyForObjectWithName(self._home._resourceID, self._name)
-            yield queryCacher.invalidateAfterCommit(self._home._txn, cacheKey)
-            cacheKey = queryCacher.keyForObjectWithResourceID(self._home._resourceID, self._resourceID)
-            yield queryCacher.invalidateAfterCommit(self._home._txn, cacheKey)
</del><ins>+        yield self.invalidateQueryCache()
</ins><span class="cx"> 
</span><span class="cx">         yield self._deletedSyncToken()
</span><del>-        yield self._deleteQuery.on(self._txn, NoSuchHomeChildError,
-                                   resourceID=self._resourceID)
</del><ins>+        yield self._deleteQuery.on(self._txn, NoSuchHomeChildError, resourceID=self._resourceID)
</ins><span class="cx">         yield self.properties()._removeResource()
</span><span class="cx"> 
</span><span class="cx">         # Set to non-existent state
</span><span class="lines">@@ -5193,6 +5539,15 @@
</span><span class="cx">             resourceID = rows[0][0]
</span><span class="cx">             created = False
</span><span class="cx">         elif create:
</span><ins>+            # Determine if the user is local or external
+            record = txn.directoryService().recordWithUID(uid)
+            if record is None:
+                raise DirectoryRecordNotFoundError(&quot;Cannot create home for UID since no directory record exists: {uid}&quot;.format(uid=uid))
+
+            state = _HOME_STATUS_NORMAL if record.thisServer() else _HOME_STATUS_EXTERNAL
+            if state == _HOME_STATUS_EXTERNAL:
+                raise RecordNotAllowedError(&quot;Cannot store notifications for external user: {uid}&quot;.format(uid=uid))
+
</ins><span class="cx">             # Use savepoint so we can do a partial rollback if there is a race
</span><span class="cx">             # condition where this row has already been inserted
</span><span class="cx">             savepoint = SavepointAction(&quot;notificationsWithUID&quot;)
</span><span class="lines">@@ -5597,6 +5952,8 @@
</span><span class="cx">                 child._notificationType = json.loads(child._notificationType)
</span><span class="cx">             except ValueError:
</span><span class="cx">                 pass
</span><ins>+            if isinstance(child._notificationType, unicode):
+                child._notificationType = child._notificationType.encode(&quot;utf-8&quot;)
</ins><span class="cx">             child._loadPropertyStore(
</span><span class="cx">                 props=propertyStores.get(child._resourceID, None)
</span><span class="cx">             )
</span><span class="lines">@@ -5645,6 +6002,8 @@
</span><span class="cx">                 self._notificationType = json.loads(self._notificationType)
</span><span class="cx">             except ValueError:
</span><span class="cx">                 pass
</span><ins>+            if isinstance(self._notificationType, unicode):
+                self._notificationType = self._notificationType.encode(&quot;utf-8&quot;)
</ins><span class="cx">             self._loadPropertyStore()
</span><span class="cx">             returnValue(self)
</span><span class="cx">         else:
</span><span class="lines">@@ -5758,6 +6117,8 @@
</span><span class="cx">                 self._notificationData = json.loads(self._notificationData)
</span><span class="cx">             except ValueError:
</span><span class="cx">                 pass
</span><ins>+            if isinstance(self._notificationData, unicode):
+                self._notificationData = self._notificationData.encode(&quot;utf-8&quot;)
</ins><span class="cx">         returnValue(self._notificationData)
</span><span class="cx"> 
</span><span class="cx"> 
</span></span></pre></div>
<a id="CalendarServerbranchesuserscdaboocrosspodsharingtxdavcommondatastoresql_schemacurrentoracledialectsql"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/sql_schema/current-oracle-dialect.sql (12040 => 12041)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/sql_schema/current-oracle-dialect.sql        2013-12-06 20:40:44 UTC (rev 12040)
+++ CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/sql_schema/current-oracle-dialect.sql        2013-12-06 21:43:35 UTC (rev 12041)
</span><span class="lines">@@ -18,9 +18,17 @@
</span><span class="cx"> create table CALENDAR_HOME (
</span><span class="cx">     &quot;RESOURCE_ID&quot; integer primary key,
</span><span class="cx">     &quot;OWNER_UID&quot; nvarchar2(255) unique,
</span><ins>+    &quot;STATUS&quot; integer default 0 not null,
</ins><span class="cx">     &quot;DATAVERSION&quot; integer default 0 not null
</span><span class="cx"> );
</span><span class="cx"> 
</span><ins>+create table HOME_STATUS (
+    &quot;ID&quot; integer primary key,
+    &quot;DESCRIPTION&quot; nvarchar2(16) unique
+);
+
+insert into HOME_STATUS (DESCRIPTION, ID) values ('normal', 0);
+insert into HOME_STATUS (DESCRIPTION, ID) values ('external', 1);
</ins><span class="cx"> create table CALENDAR (
</span><span class="cx">     &quot;RESOURCE_ID&quot; integer primary key
</span><span class="cx"> );
</span><span class="lines">@@ -50,6 +58,7 @@
</span><span class="cx"> create table NOTIFICATION_HOME (
</span><span class="cx">     &quot;RESOURCE_ID&quot; integer primary key,
</span><span class="cx">     &quot;OWNER_UID&quot; nvarchar2(255) unique,
</span><ins>+    &quot;STATUS&quot; integer default 0 not null,
</ins><span class="cx">     &quot;DATAVERSION&quot; integer default 0 not null
</span><span class="cx"> );
</span><span class="cx"> 
</span><span class="lines">@@ -210,6 +219,7 @@
</span><span class="cx">     &quot;RESOURCE_ID&quot; integer primary key,
</span><span class="cx">     &quot;ADDRESSBOOK_PROPERTY_STORE_ID&quot; integer not null,
</span><span class="cx">     &quot;OWNER_UID&quot; nvarchar2(255) unique,
</span><ins>+    &quot;STATUS&quot; integer default 0 not null,
</ins><span class="cx">     &quot;DATAVERSION&quot; integer default 0 not null
</span><span class="cx"> );
</span><span class="cx"> 
</span><span class="lines">@@ -370,7 +380,7 @@
</span><span class="cx">     &quot;VALUE&quot; nvarchar2(255)
</span><span class="cx"> );
</span><span class="cx"> 
</span><del>-insert into CALENDARSERVER (NAME, VALUE) values ('VERSION', '29');
</del><ins>+insert into CALENDARSERVER (NAME, VALUE) values ('VERSION', '30');
</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><span class="cx"> insert into CALENDARSERVER (NAME, VALUE) values ('NOTIFICATION-DATAVERSION', '1');
</span></span></pre></div>
<a id="CalendarServerbranchesuserscdaboocrosspodsharingtxdavcommondatastoresql_schemacurrentsql"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/sql_schema/current.sql (12040 => 12041)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/sql_schema/current.sql        2013-12-06 20:40:44 UTC (rev 12040)
+++ CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/sql_schema/current.sql        2013-12-06 21:43:35 UTC (rev 12041)
</span><span class="lines">@@ -53,10 +53,22 @@
</span><span class="cx"> 
</span><span class="cx"> create table CALENDAR_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
+  STATUS           integer      default 0 not null,                             -- enum HOME_STATUS
</ins><span class="cx">   DATAVERSION      integer      default 0 not null
</span><span class="cx"> );
</span><span class="cx"> 
</span><ins>+-- Enumeration of statuses
+
+create table HOME_STATUS (
+  ID          integer     primary key,
+  DESCRIPTION varchar(16) not null unique
+);
+
+insert into HOME_STATUS values (0, 'normal' );
+insert into HOME_STATUS values (1, 'external');
+
+
</ins><span class="cx"> --------------
</span><span class="cx"> -- Calendar --
</span><span class="cx"> --------------
</span><span class="lines">@@ -65,6 +77,7 @@
</span><span class="cx">   RESOURCE_ID integer   primary key default nextval('RESOURCE_ID_SEQ') -- implicit index
</span><span class="cx"> );
</span><span class="cx"> 
</span><ins>+
</ins><span class="cx"> ----------------------------
</span><span class="cx"> -- Calendar Home Metadata --
</span><span class="cx"> ----------------------------
</span><span class="lines">@@ -91,6 +104,7 @@
</span><span class="cx"> create index CALENDAR_HOME_METADATA_DEFAULT_POLLS on
</span><span class="cx">         CALENDAR_HOME_METADATA(DEFAULT_POLLS);
</span><span class="cx"> 
</span><ins>+
</ins><span class="cx"> -----------------------
</span><span class="cx"> -- Calendar Metadata --
</span><span class="cx"> -----------------------
</span><span class="lines">@@ -110,6 +124,7 @@
</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><span class="cx">   OWNER_UID   varchar(255) not null unique,                                -- implicit index
</span><ins>+  STATUS      integer      default 0 not null,                             -- enum HOME_STATUS
</ins><span class="cx">   DATAVERSION integer      default 0 not null
</span><span class="cx"> );
</span><span class="cx"> 
</span><span class="lines">@@ -139,6 +154,7 @@
</span><span class="cx"> create table CALENDAR_BIND (
</span><span class="cx">   CALENDAR_HOME_RESOURCE_ID integer      not null references CALENDAR_HOME,
</span><span class="cx">   CALENDAR_RESOURCE_ID      integer      not null references CALENDAR on delete cascade,
</span><ins>+  EXTERNAL_ID                            integer      default null,
</ins><span class="cx">   CALENDAR_RESOURCE_NAME    varchar(255) not null,
</span><span class="cx">   BIND_MODE                 integer      not null, -- enum CALENDAR_BIND_MODE
</span><span class="cx">   BIND_STATUS               integer      not null, -- enum CALENDAR_BIND_STATUS
</span><span class="lines">@@ -380,6 +396,7 @@
</span><span class="cx">   RESOURCE_ID                                      integer                        primary key default nextval('RESOURCE_ID_SEQ'), -- implicit index
</span><span class="cx">   ADDRESSBOOK_PROPERTY_STORE_ID        integer              default nextval('RESOURCE_ID_SEQ') not null,         -- implicit index
</span><span class="cx">   OWNER_UID                                        varchar(255)         not null unique,                                -- implicit index
</span><ins>+  STATUS                                           integer              default 0 not null,                             -- enum HOME_STATUS
</ins><span class="cx">   DATAVERSION                                      integer              default 0 not null
</span><span class="cx"> );
</span><span class="cx"> 
</span><span class="lines">@@ -405,6 +422,7 @@
</span><span class="cx"> create table SHARED_ADDRESSBOOK_BIND (
</span><span class="cx">   ADDRESSBOOK_HOME_RESOURCE_ID                        integer                        not null references ADDRESSBOOK_HOME,
</span><span class="cx">   OWNER_HOME_RESOURCE_ID                            integer              not null references ADDRESSBOOK_HOME on delete cascade,
</span><ins>+  EXTERNAL_ID                                        integer         default null,
</ins><span class="cx">   ADDRESSBOOK_RESOURCE_NAME                            varchar(255)         not null,
</span><span class="cx">   BIND_MODE                                            integer              not null,        -- enum CALENDAR_BIND_MODE
</span><span class="cx">   BIND_STATUS                                          integer              not null,        -- enum CALENDAR_BIND_STATUS
</span><span class="lines">@@ -495,6 +513,7 @@
</span><span class="cx"> create table SHARED_GROUP_BIND (        
</span><span class="cx">   ADDRESSBOOK_HOME_RESOURCE_ID                 integer      not null references ADDRESSBOOK_HOME,
</span><span class="cx">   GROUP_RESOURCE_ID                              integer      not null references ADDRESSBOOK_OBJECT on delete cascade,
</span><ins>+  EXTERNAL_ID                                    integer      default null,
</ins><span class="cx">   GROUP_ADDRESSBOOK_NAME                        varchar(255) not null,
</span><span class="cx">   BIND_MODE                                    integer      not null, -- enum CALENDAR_BIND_MODE
</span><span class="cx">   BIND_STATUS                                  integer      not null, -- enum CALENDAR_BIND_STATUS
</span><span class="lines">@@ -702,7 +721,7 @@
</span><span class="cx">   VALUE                         varchar(255)
</span><span class="cx"> );
</span><span class="cx"> 
</span><del>-insert into CALENDARSERVER values ('VERSION', '29');
</del><ins>+insert into CALENDARSERVER values ('VERSION', '30');
</ins><span class="cx"> insert into CALENDARSERVER values ('CALENDAR-DATAVERSION', '5');
</span><span class="cx"> insert into CALENDARSERVER values ('ADDRESSBOOK-DATAVERSION', '2');
</span><span class="cx"> insert into CALENDARSERVER values ('NOTIFICATION-DATAVERSION', '1');
</span></span></pre></div>
<a id="CalendarServerbranchesuserscdaboocrosspodsharingtxdavcommondatastoresql_schemaoldoracledialectv29sql"></a>
<div class="addfile"><h4>Added: CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/sql_schema/old/oracle-dialect/v29.sql (0 => 12041)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/sql_schema/old/oracle-dialect/v29.sql                                (rev 0)
+++ CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/sql_schema/old/oracle-dialect/v29.sql        2013-12-06 21:43:35 UTC (rev 12041)
</span><span class="lines">@@ -0,0 +1,505 @@
</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,
+    &quot;DATAVERSION&quot; integer default 0 not null
+);
+
+create table NOTIFICATION (
+    &quot;RESOURCE_ID&quot; integer primary key,
+    &quot;NOTIFICATION_HOME_RESOURCE_ID&quot; integer not null references NOTIFICATION_HOME,
+    &quot;NOTIFICATION_UID&quot; nvarchar2(255),
+    &quot;NOTIFICATION_TYPE&quot; nvarchar2(255),
+    &quot;NOTIFICATION_DATA&quot; nclob,
+    &quot;MD5&quot; nchar(32),
+    &quot;CREATED&quot; timestamp default CURRENT_TIMESTAMP at time zone 'UTC',
+    &quot;MODIFIED&quot; timestamp default CURRENT_TIMESTAMP at time zone 'UTC', 
+    unique(&quot;NOTIFICATION_UID&quot;, &quot;NOTIFICATION_HOME_RESOURCE_ID&quot;)
+);
+
+create table CALENDAR_BIND (
+    &quot;CALENDAR_HOME_RESOURCE_ID&quot; integer not null references CALENDAR_HOME,
+    &quot;CALENDAR_RESOURCE_ID&quot; integer not null references CALENDAR on delete cascade,
+    &quot;CALENDAR_RESOURCE_NAME&quot; nvarchar2(255),
+    &quot;BIND_MODE&quot; integer not null,
+    &quot;BIND_STATUS&quot; integer not null,
+    &quot;BIND_REVISION&quot; integer default 0 not null,
+    &quot;MESSAGE&quot; nclob,
+    &quot;TRANSP&quot; integer default 0 not null,
+    &quot;ALARM_VEVENT_TIMED&quot; nclob default null,
+    &quot;ALARM_VEVENT_ALLDAY&quot; nclob default null,
+    &quot;ALARM_VTODO_TIMED&quot; nclob default null,
+    &quot;ALARM_VTODO_ALLDAY&quot; nclob default null,
+    &quot;TIMEZONE&quot; nclob default null, 
+    primary key(&quot;CALENDAR_HOME_RESOURCE_ID&quot;, &quot;CALENDAR_RESOURCE_ID&quot;), 
+    unique(&quot;CALENDAR_HOME_RESOURCE_ID&quot;, &quot;CALENDAR_RESOURCE_NAME&quot;)
+);
+
+create table CALENDAR_BIND_MODE (
+    &quot;ID&quot; integer primary key,
+    &quot;DESCRIPTION&quot; nvarchar2(16) unique
+);
+
+insert into CALENDAR_BIND_MODE (DESCRIPTION, ID) values ('own', 0);
+insert into CALENDAR_BIND_MODE (DESCRIPTION, ID) values ('read', 1);
+insert into CALENDAR_BIND_MODE (DESCRIPTION, ID) values ('write', 2);
+insert into CALENDAR_BIND_MODE (DESCRIPTION, ID) values ('direct', 3);
+insert into CALENDAR_BIND_MODE (DESCRIPTION, ID) values ('indirect', 4);
+create table CALENDAR_BIND_STATUS (
+    &quot;ID&quot; integer primary key,
+    &quot;DESCRIPTION&quot; nvarchar2(16) unique
+);
+
+insert into CALENDAR_BIND_STATUS (DESCRIPTION, ID) values ('invited', 0);
+insert into CALENDAR_BIND_STATUS (DESCRIPTION, ID) values ('accepted', 1);
+insert into CALENDAR_BIND_STATUS (DESCRIPTION, ID) values ('declined', 2);
+insert into CALENDAR_BIND_STATUS (DESCRIPTION, ID) values ('invalid', 3);
+insert into CALENDAR_BIND_STATUS (DESCRIPTION, ID) values ('deleted', 4);
+create table CALENDAR_TRANSP (
+    &quot;ID&quot; integer primary key,
+    &quot;DESCRIPTION&quot; nvarchar2(16) unique
+);
+
+insert into CALENDAR_TRANSP (DESCRIPTION, ID) values ('opaque', 0);
+insert into CALENDAR_TRANSP (DESCRIPTION, ID) values ('transparent', 1);
+create table CALENDAR_OBJECT (
+    &quot;RESOURCE_ID&quot; integer primary key,
+    &quot;CALENDAR_RESOURCE_ID&quot; integer not null references CALENDAR on delete cascade,
+    &quot;RESOURCE_NAME&quot; nvarchar2(255),
+    &quot;ICALENDAR_TEXT&quot; nclob,
+    &quot;ICALENDAR_UID&quot; nvarchar2(255),
+    &quot;ICALENDAR_TYPE&quot; nvarchar2(255),
+    &quot;ATTACHMENTS_MODE&quot; integer default 0 not null,
+    &quot;DROPBOX_ID&quot; nvarchar2(255),
+    &quot;ORGANIZER&quot; nvarchar2(255),
+    &quot;RECURRANCE_MIN&quot; date,
+    &quot;RECURRANCE_MAX&quot; date,
+    &quot;ACCESS&quot; integer default 0 not null,
+    &quot;SCHEDULE_OBJECT&quot; integer default 0,
+    &quot;SCHEDULE_TAG&quot; nvarchar2(36) default null,
+    &quot;SCHEDULE_ETAGS&quot; nclob default null,
+    &quot;PRIVATE_COMMENTS&quot; integer default 0 not null,
+    &quot;MD5&quot; nchar(32),
+    &quot;CREATED&quot; timestamp default CURRENT_TIMESTAMP at time zone 'UTC',
+    &quot;MODIFIED&quot; timestamp default CURRENT_TIMESTAMP at time zone 'UTC', 
+    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', '29');
+insert into CALENDARSERVER (NAME, VALUE) values ('CALENDAR-DATAVERSION', '5');
+insert into CALENDARSERVER (NAME, VALUE) values ('ADDRESSBOOK-DATAVERSION', '2');
+insert into CALENDARSERVER (NAME, VALUE) values ('NOTIFICATION-DATAVERSION', '1');
+create index CALENDAR_HOME_METADAT_3cb9049e on CALENDAR_HOME_METADATA (
+    DEFAULT_EVENTS
+);
+
+create index CALENDAR_HOME_METADAT_d55e5548 on CALENDAR_HOME_METADATA (
+    DEFAULT_TASKS
+);
+
+create index CALENDAR_HOME_METADAT_910264ce on CALENDAR_HOME_METADATA (
+    DEFAULT_POLLS
+);
+
+create index NOTIFICATION_NOTIFICA_f891f5f9 on NOTIFICATION (
+    NOTIFICATION_HOME_RESOURCE_ID
+);
+
+create index CALENDAR_BIND_RESOURC_e57964d4 on CALENDAR_BIND (
+    CALENDAR_RESOURCE_ID
+);
+
+create index CALENDAR_OBJECT_CALEN_a9a453a9 on CALENDAR_OBJECT (
+    CALENDAR_RESOURCE_ID,
+    ICALENDAR_UID
+);
+
+create index CALENDAR_OBJECT_CALEN_96e83b73 on CALENDAR_OBJECT (
+    CALENDAR_RESOURCE_ID,
+    RECURRANCE_MAX
+);
+
+create index CALENDAR_OBJECT_ICALE_82e731d5 on CALENDAR_OBJECT (
+    ICALENDAR_UID
+);
+
+create index CALENDAR_OBJECT_DROPB_de041d80 on CALENDAR_OBJECT (
+    DROPBOX_ID
+);
+
+create index TIME_RANGE_CALENDAR_R_beb6e7eb on TIME_RANGE (
+    CALENDAR_RESOURCE_ID
+);
+
+create index TIME_RANGE_CALENDAR_O_acf37bd1 on TIME_RANGE (
+    CALENDAR_OBJECT_RESOURCE_ID
+);
+
+create index 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="CalendarServerbranchesuserscdaboocrosspodsharingtxdavcommondatastoresql_schemaoldpostgresdialectv29sql"></a>
<div class="addfile"><h4>Added: CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/sql_schema/old/postgres-dialect/v29.sql (0 => 12041)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/sql_schema/old/postgres-dialect/v29.sql                                (rev 0)
+++ CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/sql_schema/old/postgres-dialect/v29.sql        2013-12-06 21:43:35 UTC (rev 12041)
</span><span class="lines">@@ -0,0 +1,708 @@
</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
+  DATAVERSION integer      default 0 not null
+);
+
+create table NOTIFICATION (
+  RESOURCE_ID                   integer      primary key default nextval('RESOURCE_ID_SEQ'), -- implicit index
+  NOTIFICATION_HOME_RESOURCE_ID integer      not null references NOTIFICATION_HOME,
+  NOTIFICATION_UID              varchar(255) not null,
+  NOTIFICATION_TYPE             varchar(255) not null,
+  NOTIFICATION_DATA             text         not null,
+  MD5                           char(32)     not null,
+  CREATED                       timestamp    default timezone('UTC', CURRENT_TIMESTAMP),
+  MODIFIED                      timestamp    default timezone('UTC', CURRENT_TIMESTAMP),
+
+  unique(NOTIFICATION_UID, NOTIFICATION_HOME_RESOURCE_ID) -- implicit index
+);
+
+create index NOTIFICATION_NOTIFICATION_HOME_RESOURCE_ID on
+        NOTIFICATION(NOTIFICATION_HOME_RESOURCE_ID);
+
+
+-------------------
+-- Calendar Bind --
+-------------------
+
+-- Joins CALENDAR_HOME and CALENDAR
+
+create table CALENDAR_BIND (
+  CALENDAR_HOME_RESOURCE_ID integer      not null references CALENDAR_HOME,
+  CALENDAR_RESOURCE_ID      integer      not null references CALENDAR on delete cascade,
+  CALENDAR_RESOURCE_NAME    varchar(255) not null,
+  BIND_MODE                 integer      not null, -- enum CALENDAR_BIND_MODE
+  BIND_STATUS               integer      not null, -- enum CALENDAR_BIND_STATUS
+  BIND_REVISION                                integer      default 0 not null,
+  MESSAGE                   text,
+  TRANSP                    integer      default 0 not null, -- enum CALENDAR_TRANSP
+  ALARM_VEVENT_TIMED        text         default null,
+  ALARM_VEVENT_ALLDAY       text         default null,
+  ALARM_VTODO_TIMED         text         default null,
+  ALARM_VTODO_ALLDAY        text         default null,
+  TIMEZONE                  text         default null,
+
+  primary key(CALENDAR_HOME_RESOURCE_ID, CALENDAR_RESOURCE_ID), -- implicit index
+  unique(CALENDAR_HOME_RESOURCE_ID, CALENDAR_RESOURCE_NAME)     -- implicit index
+);
+
+create index CALENDAR_BIND_RESOURCE_ID on
+        CALENDAR_BIND(CALENDAR_RESOURCE_ID);
+
+-- Enumeration of calendar bind modes
+
+create table CALENDAR_BIND_MODE (
+  ID          integer     primary key,
+  DESCRIPTION varchar(16) not null unique
+);
+
+insert into CALENDAR_BIND_MODE values (0, 'own'  );
+insert into CALENDAR_BIND_MODE values (1, 'read' );
+insert into CALENDAR_BIND_MODE values (2, 'write');
+insert into CALENDAR_BIND_MODE values (3, 'direct');
+insert into CALENDAR_BIND_MODE values (4, 'indirect');
+
+-- Enumeration of statuses
+
+create table CALENDAR_BIND_STATUS (
+  ID          integer     primary key,
+  DESCRIPTION varchar(16) not null unique
+);
+
+insert into CALENDAR_BIND_STATUS values (0, 'invited' );
+insert into CALENDAR_BIND_STATUS values (1, 'accepted');
+insert into CALENDAR_BIND_STATUS values (2, 'declined');
+insert into CALENDAR_BIND_STATUS values (3, 'invalid');
+insert into CALENDAR_BIND_STATUS values (4, 'deleted');
+
+
+-- Enumeration of transparency
+
+create table CALENDAR_TRANSP (
+  ID          integer     primary key,
+  DESCRIPTION varchar(16) not null unique
+);
+
+insert into CALENDAR_TRANSP values (0, 'opaque' );
+insert into CALENDAR_TRANSP values (1, 'transparent');
+
+
+---------------------
+-- Calendar Object --
+---------------------
+
+create table CALENDAR_OBJECT (
+  RESOURCE_ID          integer      primary key default nextval('RESOURCE_ID_SEQ'), -- implicit index
+  CALENDAR_RESOURCE_ID integer      not null references CALENDAR on delete cascade,
+  RESOURCE_NAME        varchar(255) not null,
+  ICALENDAR_TEXT       text         not null,
+  ICALENDAR_UID        varchar(255) not null,
+  ICALENDAR_TYPE       varchar(255) not null,
+  ATTACHMENTS_MODE     integer      default 0 not null, -- enum CALENDAR_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', '29');
+insert into CALENDARSERVER values ('CALENDAR-DATAVERSION', '5');
+insert into CALENDARSERVER values ('ADDRESSBOOK-DATAVERSION', '2');
+insert into CALENDARSERVER values ('NOTIFICATION-DATAVERSION', '1');
</ins></span></pre></div>
<a id="CalendarServerbranchesuserscdaboocrosspodsharingtxdavcommondatastoresql_schemaupgradesoracledialectupgrade_from_29_to_30sql"></a>
<div class="addfile"><h4>Added: CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_29_to_30.sql (0 => 12041)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_29_to_30.sql                                (rev 0)
+++ CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_29_to_30.sql        2013-12-06 21:43:35 UTC (rev 12041)
</span><span class="lines">@@ -0,0 +1,53 @@
</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 29 to 30 --
+---------------------------------------------------
+
+-- Home related updates
+
+alter table CALENDAR_HOME
+ add (&quot;STATUS&quot; integer default 0 not null);
+
+alter table NOTIFICATION_HOME
+ add (&quot;STATUS&quot; integer default 0 not null);
+
+alter table ADDRESSBOOK_HOME
+ add (&quot;STATUS&quot; integer default 0 not null);
+
+create table HOME_STATUS (
+    &quot;ID&quot; integer primary key,
+    &quot;DESCRIPTION&quot; nvarchar2(16) unique
+);
+
+insert into HOME_STATUS (DESCRIPTION, ID) values ('normal', 0);
+insert into HOME_STATUS (DESCRIPTION, ID) values ('external', 1);
+
+-- Bind changes
+alter table CALENDAR_BIND
+ add (&quot;EXTERNAL_ID&quot; integer default null);
+
+alter table SHARED_ADDRESSBOOK_BIND
+ add (&quot;EXTERNAL_ID&quot; integer default null);
+
+alter table SHARED_GROUP_BIND
+ add (&quot;EXTERNAL_ID&quot; integer default null);
+
+
+-- Now update the version
+-- No data upgrades
+update CALENDARSERVER set VALUE = '30' where NAME = 'VERSION';
</ins></span></pre></div>
<a id="CalendarServerbranchesuserscdaboocrosspodsharingtxdavcommondatastoresql_schemaupgradespostgresdialectupgrade_from_29_to_30sql"></a>
<div class="addfile"><h4>Added: CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/sql_schema/upgrades/postgres-dialect/upgrade_from_29_to_30.sql (0 => 12041)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/sql_schema/upgrades/postgres-dialect/upgrade_from_29_to_30.sql                                (rev 0)
+++ CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/sql_schema/upgrades/postgres-dialect/upgrade_from_29_to_30.sql        2013-12-06 21:43:35 UTC (rev 12041)
</span><span class="lines">@@ -0,0 +1,55 @@
</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 29 to 30 --
+---------------------------------------------------
+
+-- Home related updates
+
+alter table CALENDAR_HOME
+ add column STATUS integer default 0 not null;
+
+alter table NOTIFICATION_HOME
+ add column STATUS integer default 0 not null;
+
+alter table ADDRESSBOOK_HOME
+ add column STATUS integer default 0 not null;
+
+-- Enumeration of statuses
+
+create table HOME_STATUS (
+  ID          integer     primary key,
+  DESCRIPTION varchar(16) not null unique
+);
+
+insert into HOME_STATUS values (0, 'normal' );
+insert into HOME_STATUS values (1, 'external');
+
+-- Bind changes
+alter table CALENDAR_BIND
+ add column EXTERNAL_ID integer default null;
+
+alter table SHARED_ADDRESSBOOK_BIND
+ add column EXTERNAL_ID integer default null;
+
+alter table SHARED_GROUP_BIND
+ add column EXTERNAL_ID integer default null;
+
+
+-- Now update the version
+-- No data upgrades
+update CALENDARSERVER set VALUE = '30' where NAME = 'VERSION';
</ins></span></pre></div>
<a id="CalendarServerbranchesuserscdaboocrosspodsharingtxdavcommondatastoresql_tablespy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/sql_tables.py (12040 => 12041)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/sql_tables.py        2013-12-06 20:40:44 UTC (rev 12040)
+++ CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/sql_tables.py        2013-12-06 21:43:35 UTC (rev 12041)
</span><span class="lines">@@ -133,6 +133,15 @@
</span><span class="cx"> 
</span><span class="cx"> # Various constants
</span><span class="cx"> 
</span><ins>+_homeStatus = _schemaConstants(
+    schema.HOME_STATUS.DESCRIPTION,
+    schema.HOME_STATUS.ID
+)
+
+
+_HOME_STATUS_NORMAL = _homeStatus('normal')
+_HOME_STATUS_EXTERNAL = _homeStatus('external')
+
</ins><span class="cx"> _bindStatus = _schemaConstants(
</span><span class="cx">     schema.CALENDAR_BIND_STATUS.DESCRIPTION,
</span><span class="cx">     schema.CALENDAR_BIND_STATUS.ID
</span></span></pre></div>
<a id="CalendarServerbranchesuserscdaboocrosspodsharingtxdavcommonicommondatastorepy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/icommondatastore.py (12040 => 12041)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/icommondatastore.py        2013-12-06 20:40:44 UTC (rev 12040)
+++ CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/icommondatastore.py        2013-12-06 21:43:35 UTC (rev 12041)
</span><span class="lines">@@ -51,6 +51,13 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+class RecordNotAllowedError(CommonStoreError):
+    &quot;&quot;&quot;
+    User not allowed.
+    &quot;&quot;&quot;
+
+
+
</ins><span class="cx"> class NameNotAllowedError(CommonStoreError):
</span><span class="cx">     &quot;&quot;&quot;
</span><span class="cx">     Attempt to create an object with a name that is not allowed.
</span><span class="lines">@@ -205,6 +212,13 @@
</span><span class="cx">     &quot;&quot;&quot;
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+
+class ExternalShareFailed(CommonStoreError):
+    &quot;&quot;&quot;
+    An external sharee operation failed.
+    &quot;&quot;&quot;
+
+
</ins><span class="cx"> # Indexing / sync tokens
</span><span class="cx"> 
</span><span class="cx"> 
</span></span></pre></div>
<a id="CalendarServerbranchesuserscdaboocrosspodsharingtxdavcommonidirectoryservicepy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/idirectoryservice.py (12040 => 12041)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/idirectoryservice.py        2013-12-06 20:40:44 UTC (rev 12040)
+++ CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/idirectoryservice.py        2013-12-06 21:43:35 UTC (rev 12041)
</span><span class="lines">@@ -26,6 +26,20 @@
</span><span class="cx">     &quot;IStoreDirectoryRecord&quot;,
</span><span class="cx"> ]
</span><span class="cx"> 
</span><ins>+class IStoreDirectoryError(Exception):
+    &quot;&quot;&quot;
+    Base class for directory related errors.
+    &quot;&quot;&quot;
+
+
+
+class DirectoryRecordNotFoundError(Exception):
+    &quot;&quot;&quot;
+    Directory record not found.
+    &quot;&quot;&quot;
+
+
+
</ins><span class="cx"> class IStoreDirectoryService(Interface):
</span><span class="cx">     &quot;&quot;&quot;
</span><span class="cx">     Directory Service for looking up users.
</span><span class="lines">@@ -55,3 +69,27 @@
</span><span class="cx">     fullName = Attribute(&quot;Full name for the entity associated with the record: C{str}&quot;)
</span><span class="cx"> 
</span><span class="cx">     displayName = Attribute(&quot;Display name for entity associated with the record: C{str}&quot;)
</span><ins>+
+    def serverURI(): #@NoSelf
+        &quot;&quot;&quot;
+        Return the URI for the record's server &quot;pod&quot;.
+
+        @return: a URI.
+        @rtype: C{str}
+        &quot;&quot;&quot;
+
+    def server(): #@NoSelf
+        &quot;&quot;&quot;
+        Return the L{txdav.caldav.datastore.scheduling.localservers.Server} for the record's server &quot;pod&quot;.
+
+        @return: a pod server record.
+        @rtype: L{txdav.caldav.datastore.scheduling.localservers.Server}
+        &quot;&quot;&quot;
+
+    def thisServer(): #@NoSelf
+        &quot;&quot;&quot;
+        Indicates whether the record is hosted on this server &quot;pod&quot;.
+
+        @return: C{True} if hosted by this service.
+        @rtype: C{bool}
+        &quot;&quot;&quot;
</ins></span></pre>
</div>
</div>

</body>
</html>