[CalendarServer-changes] [12187] CalendarServer/branches/users/cdaboo/cross-pod-sharing
source_changes at macosforge.org
source_changes at macosforge.org
Wed Mar 12 11:23:13 PDT 2014
Revision: 12187
http://trac.calendarserver.org//changeset/12187
Author: cdaboo at apple.com
Date: 2013-12-21 14:50:14 -0800 (Sat, 21 Dec 2013)
Log Message:
-----------
Checkpoint: cross-pod direct sharing.
Modified Paths:
--------------
CalendarServer/branches/users/cdaboo/cross-pod-sharing/conf/caldavd-test-podB.plist
CalendarServer/branches/users/cdaboo/cross-pod-sharing/twistedcaldav/directory/principal.py
CalendarServer/branches/users/cdaboo/cross-pod-sharing/twistedcaldav/sharing.py
CalendarServer/branches/users/cdaboo/cross-pod-sharing/twistedcaldav/storebridge.py
CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/podding/conduit.py
CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/sql.py
Modified: CalendarServer/branches/users/cdaboo/cross-pod-sharing/conf/caldavd-test-podB.plist
===================================================================
--- CalendarServer/branches/users/cdaboo/cross-pod-sharing/conf/caldavd-test-podB.plist 2013-12-21 22:48:59 UTC (rev 12186)
+++ CalendarServer/branches/users/cdaboo/cross-pod-sharing/conf/caldavd-test-podB.plist 2013-12-21 22:50:14 UTC (rev 12187)
@@ -101,6 +101,19 @@
</dict>
</dict>
+ <!-- Sqlite ProxyDB Service - must use the same one as Pod A-->
+ <key>ProxyDBService</key>
+ <dict>
+ <key>type</key>
+ <string>twistedcaldav.directory.calendaruserproxy.ProxySqliteDB</string>
+
+ <key>params</key>
+ <dict>
+ <key>dbpath</key>
+ <string>./data/podA/Data/proxies.sqlite</string>
+ </dict>
+ </dict>
+
<key>ProxyLoadFromFile</key>
<string>./conf/auth/proxies-test-pod.xml</string>
Modified: CalendarServer/branches/users/cdaboo/cross-pod-sharing/twistedcaldav/directory/principal.py
===================================================================
--- CalendarServer/branches/users/cdaboo/cross-pod-sharing/twistedcaldav/directory/principal.py 2013-12-21 22:48:59 UTC (rev 12186)
+++ CalendarServer/branches/users/cdaboo/cross-pod-sharing/twistedcaldav/directory/principal.py 2013-12-21 22:50:14 UTC (rev 12187)
@@ -922,6 +922,23 @@
@inlineCallbacks
+ def proxyMode(self, principal):
+ """
+ Determine whether what proxy mode this principal has in relation to the one specified.
+ """
+
+ read_uids = (yield self.proxyFor(False))
+ if principal in read_uids:
+ returnValue("read")
+
+ write_uids = (yield self.proxyFor(True))
+ if principal in write_uids:
+ returnValue("write")
+
+ returnValue("none")
+
+
+ @inlineCallbacks
def proxyFor(self, read_write, resolve_memberships=True):
proxyFors = set()
Modified: CalendarServer/branches/users/cdaboo/cross-pod-sharing/twistedcaldav/sharing.py
===================================================================
--- CalendarServer/branches/users/cdaboo/cross-pod-sharing/twistedcaldav/sharing.py 2013-12-21 22:48:59 UTC (rev 12186)
+++ CalendarServer/branches/users/cdaboo/cross-pod-sharing/twistedcaldav/sharing.py 2013-12-21 22:50:14 UTC (rev 12187)
@@ -267,10 +267,10 @@
"""
if self._newStoreObject.direct():
owner = self.principalForUID(self._newStoreObject.ownerHome().uid())
+ sharee = self.principalForUID(self._newStoreObject.viewerHome().uid())
if owner.record.recordType == WikiDirectoryService.recordType_wikis:
# Access level comes from what the wiki has granted to the
# sharee
- sharee = self.principalForUID(self._newStoreObject.viewerHome().uid())
userID = sharee.record.guid
wikiID = owner.record.shortNames[0]
access = (yield getWikiAccess(userID, wikiID))
@@ -281,7 +281,12 @@
else:
returnValue(None)
else:
- returnValue("original")
+ # Check proxy access
+ proxy_mode = yield sharee.proxyMode(owner)
+ if proxy_mode == "none":
+ returnValue("original")
+ else:
+ returnValue("read-write" if proxy_mode == "write" else "read-only")
else:
# Invited shares use access mode from the invite
# Get the access for self
@@ -318,7 +323,7 @@
sharee = self.principalForUID(self._newStoreObject.viewerHome().uid())
access = yield self._checkAccessControl()
- if access == "original":
+ if access == "original" and not self._newStoreObject.ownerHome().external():
original = (yield request.locateResource(self._share_url))
result = (yield original.accessControlList(request, *args, **kwargs))
returnValue(result)
Modified: CalendarServer/branches/users/cdaboo/cross-pod-sharing/twistedcaldav/storebridge.py
===================================================================
--- CalendarServer/branches/users/cdaboo/cross-pod-sharing/twistedcaldav/storebridge.py 2013-12-21 22:48:59 UTC (rev 12186)
+++ CalendarServer/branches/users/cdaboo/cross-pod-sharing/twistedcaldav/storebridge.py 2013-12-21 22:50:14 UTC (rev 12187)
@@ -495,11 +495,6 @@
# Now do normal delete
- # Handle sharing
- wasShared = self.isShared()
- if wasShared:
- yield self.downgradeFromShare(request)
-
# Actually delete it.
yield self._newStoreObject.remove()
Modified: CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/podding/conduit.py
===================================================================
--- CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/podding/conduit.py 2013-12-21 22:48:59 UTC (rev 12186)
+++ CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/podding/conduit.py 2013-12-21 22:50:14 UTC (rev 12187)
@@ -378,66 +378,6 @@
})
- @inlineCallbacks
- def send_shareremove(self, txn, homeType, ownerUID, shareeUID, shareUID):
- """
- Send a sharing remove 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 recipient
- @type shareeUID: C{str}
- @param shareUID: Resource/invite ID for recipient
- @type shareUID: C{str}
- """
-
- _ignore_sender, recipient = self.validRequst(shareeUID, ownerUID)
-
- action = {
- "action": "shareremove",
- "type": homeType,
- "owner": ownerUID,
- "sharee": shareeUID,
- "share_id": shareUID,
- }
-
- result = yield self.sendRequest(txn, recipient, action)
- returnValue(result)
-
-
- @inlineCallbacks
- def recv_shareremove(self, txn, message):
- """
- Process a sharing remove cross-pod message. Message arguments as per L{send_shareremove}.
-
- @param message: message arguments
- @type message: C{dict}
- """
-
- if message["action"] != "shareremove":
- raise FailedCrossPodRequestError("Wrong action '{}' for recv_shareremove".format(message["action"]))
-
- # Create a share
- ownerHome = yield txn.homeWithUID(message["type"], message["owner"])
- if ownerHome is None or ownerHome.external():
- FailedCrossPodRequestError("Invalid owner UID specified")
-
- try:
- yield ownerHome.processExternalRemove(
- message["owner"],
- message["sharee"],
- message["share_id"],
- )
- except ExternalShareFailed as e:
- FailedCrossPodRequestError(str(e))
-
- returnValue({
- "result": "ok",
- })
-
-
#
# Sharer data access related apis
#
Modified: CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/sql.py
===================================================================
--- CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/sql.py 2013-12-21 22:48:59 UTC (rev 12186)
+++ CalendarServer/branches/users/cdaboo/cross-pod-sharing/txdav/common/datastore/sql.py 2013-12-21 22:50:14 UTC (rev 12187)
@@ -1568,32 +1568,13 @@
if bindStatus == _BIND_STATUS_ACCEPTED:
yield shareeHome.acceptShare(shareUID, summary)
elif bindStatus == _BIND_STATUS_DECLINED:
- yield shareeHome.declineShare(shareUID)
+ if shareeView.direct():
+ yield shareeView.deleteShare()
+ else:
+ yield shareeHome.declineShare(shareUID)
- @inlineCallbacks
- def processExternalRemove(self, ownerUID, shareeUID, shareUID):
- """
- External invite received.
- """
- # 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("Invalid sharee UID: {}".format(shareeUID))
-
- # Try to find owner calendar via its external id
- shareeView = yield shareeHome.anyObjectWithShareUID(shareUID)
- if shareeView is None:
- raise ExternalShareFailed("Invalid share UID: {}".format(shareUID))
-
- # Now carry out the share operation
- yield shareeView.deleteShare()
-
-
-
class CommonHome(SharingHomeMixIn):
log = Logger()
@@ -3219,18 +3200,32 @@
@inlineCallbacks
def deleteShare(self):
"""
- This share is being deleted - either decline or remove (for direct shares).
+ This share is being deleted (by the sharee) - either decline or remove (for direct shares).
"""
ownerView = yield self.ownerView()
if self.direct():
yield ownerView.removeShare(self)
if ownerView.external():
- yield self._removeExternalInvite()
+ yield self._replyExternalInvite(_BIND_STATUS_DECLINED)
else:
yield self.declineShare()
+ @inlineCallbacks
+ def ownerDeleteShare(self):
+ """
+ This share is being deleted (by the owner) - either decline or remove (for direct shares).
+ """
+
+ # Change status on store object
+ yield self.setShared(False)
+
+ # Remove all sharees (direct and invited)
+ for invitation in (yield self.sharingInvites()):
+ yield self.uninviteUserFromShare(invitation.shareeUID)
+
+
def newShare(self, displayname=None):
"""
Override in derived classes to do any specific operations needed when a share
@@ -3371,24 +3366,12 @@
self.viewerHome()._homeType,
self.ownerHome().uid(),
self.viewerHome().uid(),
- self.shareName(),
+ self.shareUID(),
status,
summary,
)
- @inlineCallbacks
- def _removeExternalInvite(self):
-
- yield self._txn.store().conduit.send_shareremove(
- self._txn,
- self.viewerHome()._homeType,
- self.ownerHome().uid(),
- self.viewerHome().uid(),
- self.shareName(),
- )
-
-
#
# Lower level API
#
@@ -4422,6 +4405,9 @@
@inlineCallbacks
def remove(self):
+ # Stop sharing first
+ yield self.ownerDeleteShare()
+
# Do before setting _resourceID making changes
yield self.notifyPropertyChanged()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140312/ccc7f905/attachment.html>
More information about the calendarserver-changes
mailing list