apps/federatedfilesharing/lib/FederatedShareProvider.php
/**
	 * create federated share and inform the recipient
	 *
	 * @param IShare $share
	 * @return int
	 * @throws ShareNotFound
	 * @throws \Exception
	 */
create federated share and inform the recipient
@param IShare $share
@return int
@throws ShareNotFound
@throws \Exception
create federated share and inform the recipient @param IShare $share @return int @throws ShareNotFound @throws \ Exception
protected function createFederatedShare(IShare $share) {
		$token = $this->tokenHandler->generateToken();
		$shareId = $this->addShareToDB(
			$share->getNodeId(),
			$share->getNodeType(),
			$share->getSharedWith(),
			$share->getSharedBy(),
			$share->getShareOwner(),
			$share->getPermissions(),
			$token
		);
		$failure = false;
		try {
			$sharedByFederatedId = $share->getSharedBy();
			if ($this->userManager->userExists($sharedByFederatedId)) {
				$cloudId = $this->cloudIdManager->getCloudId($sharedByFederatedId, $this->addressHandler->generateRemoteURL());
				$sharedByFederatedId = $cloudId->getId();
			}
			$ownerCloudId = $this->cloudIdManager->getCloudId($share->getShareOwner(), $this->addressHandler->generateRemoteURL());
			$send = $this->notifications->sendRemoteShare(
				$token,
				$share->getSharedWith(),
				$share->getNode()->getName(),
				$shareId,
				$share->getShareOwner(),
				$ownerCloudId->getId(),
				$share->getSharedBy(),
				$sharedByFederatedId
			);
			if ($send === false) {
				$failure = true;
			}
		} catch (\Exception $e) {
			$this->logger->error('Failed to notify remote server of federated share, removing share (' . $e->getMessage() . ')');
			$failure = true;
		}
		if($failure) {
			$this->removeShareFromTableById($shareId);
			$message_t = $this->l->t('Sharing %s failed, could not find %s, maybe the server is currently unreachable or uses a self-signed certificate.',
				[$share->getNode()->getName(), $share->getSharedWith()]);
			throw new \Exception($message_t);
		}
		return $shareId;
	}
protected function createFederatedShare ( IShare $ share ) { $ token = $ this -> tokenHandler -> generateToken ( ) ; $ shareId = $ this -> addShareToDB ( $ share -> getNodeId ( ) , $ share -> getNodeType ( ) , $ share -> getSharedWith ( ) , $ share -> getSharedBy ( ) , $ share -> getShareOwner ( ) , $ share -> getPermissions ( ) , $ token ) ; $ failure = false ; try { $ sharedByFederatedId = $ share -> getSharedBy ( ) ; if ( $ this -> userManager -> userExists ( $ sharedByFederatedId ) ) { $ cloudId = $ this -> cloudIdManager -> getCloudId ( $ sharedByFederatedId , $ this -> addressHandler -> generateRemoteURL ( ) ) ; $ sharedByFederatedId = $ cloudId -> getId ( ) ; } $ ownerCloudId = $ this -> cloudIdManager -> getCloudId ( $ share -> getShareOwner ( ) , $ this -> addressHandler -> generateRemoteURL ( ) ) ; $ send = $ this -> notifications -> sendRemoteShare ( $ token , $ share -> getSharedWith ( ) , $ share -> getNode ( ) -> getName ( ) , $ shareId , $ share -> getShareOwner ( ) , $ ownerCloudId -> getId ( ) , $ share -> getSharedBy ( ) , $ sharedByFederatedId ) ; if ( $ send === false ) { $ failure = true ; } } catch ( \ Exception $ e ) { $ this -> logger -> error ( 'Failed to notify remote server of federated share, removing share (' . $ e -> getMessage ( ) . ')' ) ; $ failure = true ; } if ( $ failure ) { $ this -> removeShareFromTableById ( $ shareId ) ; $ message_t = $ this -> l -> t ( 'Sharing %s failed, could not find %s, maybe the server is currently unreachable or uses a self-signed certificate.' , [ $ share -> getNode ( ) -> getName ( ) , $ share -> getSharedWith ( ) ] ) ; throw new \ Exception ( $ message_t ) ; } return $ shareId ; }
create federated share and inform the recipient
 @param IShare $share
 @return int
 @throws ShareNotFound
 @throws \Exception
create federated share and inform the recipient @param IShare $share @return int @throws ShareNotFound @throws \ Exception