コード例 #1
0
 /**
  * @NoAdminRequired
  *
  * @param $id
  * @return JSONResponse
  */
 public function destroy($id)
 {
     if ($this->incomingShareEnabled) {
         $this->externalManager->declineShare($id);
     }
     return new JSONResponse();
 }
コード例 #2
0
ファイル: remote.php プロジェクト: ninjasilicon/core
 /**
  * Decline a remote share
  *
  * @param array $params contains the shareID 'id' which should be declined
  * @return \OC_OCS_Result
  */
 public static function declineShare($params)
 {
     $externalManager = new Manager(\OC::$server->getDatabaseConnection(), Filesystem::getMountManager(), Filesystem::getLoader(), \OC::$server->getHTTPHelper(), \OC_User::getUser());
     if ($externalManager->declineShare($params['id'])) {
         return new \OC_OCS_Result();
     }
     return new \OC_OCS_Result(null, 404, "wrong share ID, share doesn't exist.");
 }
コード例 #3
0
ファイル: storage.php プロジェクト: lchen01/STEdwards
 /**
  * Check whether this storage is permanently or temporarily
  * unavailable
  *
  * @throws \OCP\Files\StorageNotAvailableException
  * @throws \OCP\Files\StorageInvalidException
  */
 public function checkStorageAvailability()
 {
     // see if we can find out why the share is unavailable
     try {
         $this->getShareInfo();
     } catch (NotFoundException $e) {
         // a 404 can either mean that the share no longer exists or there is no ownCloud on the remote
         if ($this->testRemote()) {
             // valid ownCloud instance means that the public share no longer exists
             // since this is permanent (re-sharing the file will create a new token)
             // we remove the invalid storage
             $this->manager->removeShare($this->mountPoint);
             $this->manager->getMountManager()->removeMount($this->mountPoint);
             throw new StorageInvalidException();
         } else {
             // ownCloud instance is gone, likely to be a temporary server configuration error
             throw new StorageNotAvailableException();
         }
     } catch (ForbiddenException $e) {
         // auth error, remove share for now (provide a dialog in the future)
         $this->manager->removeShare($this->mountPoint);
         $this->manager->getMountManager()->removeMount($this->mountPoint);
         throw new StorageInvalidException();
     } catch (\GuzzleHttp\Exception\ConnectException $e) {
         throw new StorageNotAvailableException();
     } catch (\GuzzleHttp\Exception\RequestException $e) {
         throw new StorageNotAvailableException();
     } catch (\Exception $e) {
         throw $e;
     }
 }
コード例 #4
0
ファイル: storage.php プロジェクト: Romua1d/core
 /**
  * check if a file or folder has been updated since $time
  *
  * @param string $path
  * @param int $time
  * @throws \OCP\Files\StorageNotAvailableException
  * @throws \OCP\Files\StorageInvalidException
  * @return bool
  */
 public function hasUpdated($path, $time)
 {
     // since for owncloud webdav servers we can rely on etag propagation we only need to check the root of the storage
     // because of that we only do one check for the entire storage per request
     if ($this->updateChecked) {
         return false;
     }
     $this->updateChecked = true;
     try {
         return parent::hasUpdated('', $time);
     } catch (StorageNotAvailableException $e) {
         // see if we can find out why the share is unavailable\
         try {
             $this->getShareInfo();
         } catch (NotFoundException $shareException) {
             // a 404 can either mean that the share no longer exists or there is no ownCloud on the remote
             if ($this->testRemote()) {
                 // valid ownCloud instance means that the public share no longer exists
                 // since this is permanent (re-sharing the file will create a new token)
                 // we remove the invalid storage
                 $this->manager->removeShare($this->mountPoint);
                 $this->manager->getMountManager()->removeMount($this->mountPoint);
                 throw new StorageInvalidException();
             } else {
                 // ownCloud instance is gone, likely to be a temporary server configuration error
                 throw $e;
             }
         } catch (\Exception $shareException) {
             // todo, maybe handle 403 better and ask the user for a new password
             throw $e;
         }
         throw $e;
     }
 }
コード例 #5
0
ファイル: mount.php プロジェクト: heldernl/owncloud8-extended
 /**
  * Remove the mount points
  *
  * @return mixed
  * @return bool
  */
 public function removeMount()
 {
     return $this->manager->removeShare($this->mountPoint);
 }
コード例 #6
0
 public function testDestroy()
 {
     $this->externalManager->expects($this->once())->method('declineShare')->with(4);
     $this->assertEquals(new JSONResponse(), $this->getExternalShareController()->destroy(4));
 }
コード例 #7
0
 public function testAddShare()
 {
     $shareData1 = ['remote' => 'http://localhost', 'token' => 'token1', 'password' => '', 'name' => '/SharedFolder', 'owner' => 'foobar', 'accepted' => false, 'user' => $this->uid];
     $shareData2 = $shareData1;
     $shareData2['token'] = 'token2';
     $shareData3 = $shareData1;
     $shareData3['token'] = 'token3';
     // Add a share for "user"
     $this->assertSame(null, call_user_func_array([$this->manager, 'addShare'], $shareData1));
     $openShares = $this->manager->getOpenShares();
     $this->assertCount(1, $openShares);
     $this->assertExternalShareEntry($shareData1, $openShares[0], 1, '{{TemporaryMountPointName#' . $shareData1['name'] . '}}');
     \Test_Helper::invokePrivate($this->manager, 'setupMounts');
     $this->assertNotMount('SharedFolder');
     $this->assertNotMount('{{TemporaryMountPointName#' . $shareData1['name'] . '}}');
     // Add a second share for "user" with the same name
     $this->assertSame(null, call_user_func_array([$this->manager, 'addShare'], $shareData2));
     $openShares = $this->manager->getOpenShares();
     $this->assertCount(2, $openShares);
     $this->assertExternalShareEntry($shareData1, $openShares[0], 1, '{{TemporaryMountPointName#' . $shareData1['name'] . '}}');
     // New share falls back to "-1" appendix, because the name is already taken
     $this->assertExternalShareEntry($shareData2, $openShares[1], 2, '{{TemporaryMountPointName#' . $shareData2['name'] . '}}-1');
     \Test_Helper::invokePrivate($this->manager, 'setupMounts');
     $this->assertNotMount('SharedFolder');
     $this->assertNotMount('{{TemporaryMountPointName#' . $shareData1['name'] . '}}');
     $this->assertNotMount('{{TemporaryMountPointName#' . $shareData1['name'] . '}}-1');
     // Accept the first share
     $this->manager->acceptShare($openShares[0]['id']);
     // Check remaining shares - Accepted
     $acceptedShares = \Test_Helper::invokePrivate($this->manager, 'getShares', [true]);
     $this->assertCount(1, $acceptedShares);
     $shareData1['accepted'] = true;
     $this->assertExternalShareEntry($shareData1, $acceptedShares[0], 1, $shareData1['name']);
     // Check remaining shares - Open
     $openShares = $this->manager->getOpenShares();
     $this->assertCount(1, $openShares);
     $this->assertExternalShareEntry($shareData2, $openShares[0], 2, '{{TemporaryMountPointName#' . $shareData2['name'] . '}}-1');
     \Test_Helper::invokePrivate($this->manager, 'setupMounts');
     $this->assertMount($shareData1['name']);
     $this->assertNotMount('{{TemporaryMountPointName#' . $shareData1['name'] . '}}');
     $this->assertNotMount('{{TemporaryMountPointName#' . $shareData1['name'] . '}}-1');
     // Add another share for "user" with the same name
     $this->assertSame(null, call_user_func_array([$this->manager, 'addShare'], $shareData3));
     $openShares = $this->manager->getOpenShares();
     $this->assertCount(2, $openShares);
     $this->assertExternalShareEntry($shareData2, $openShares[0], 2, '{{TemporaryMountPointName#' . $shareData2['name'] . '}}-1');
     // New share falls back to the original name (no "-\d", because the name is not taken)
     $this->assertExternalShareEntry($shareData3, $openShares[1], 3, '{{TemporaryMountPointName#' . $shareData3['name'] . '}}');
     \Test_Helper::invokePrivate($this->manager, 'setupMounts');
     $this->assertMount($shareData1['name']);
     $this->assertNotMount('{{TemporaryMountPointName#' . $shareData1['name'] . '}}');
     $this->assertNotMount('{{TemporaryMountPointName#' . $shareData1['name'] . '}}-1');
     // Decline the third share
     $this->manager->declineShare($openShares[1]['id']);
     \Test_Helper::invokePrivate($this->manager, 'setupMounts');
     $this->assertMount($shareData1['name']);
     $this->assertNotMount('{{TemporaryMountPointName#' . $shareData1['name'] . '}}');
     $this->assertNotMount('{{TemporaryMountPointName#' . $shareData1['name'] . '}}-1');
     // Check remaining shares - Accepted
     $acceptedShares = \Test_Helper::invokePrivate($this->manager, 'getShares', [true]);
     $this->assertCount(1, $acceptedShares);
     $shareData1['accepted'] = true;
     $this->assertExternalShareEntry($shareData1, $acceptedShares[0], 1, $shareData1['name']);
     // Check remaining shares - Open
     $openShares = $this->manager->getOpenShares();
     $this->assertCount(1, $openShares);
     $this->assertExternalShareEntry($shareData2, $openShares[0], 2, '{{TemporaryMountPointName#' . $shareData2['name'] . '}}-1');
     \Test_Helper::invokePrivate($this->manager, 'setupMounts');
     $this->assertMount($shareData1['name']);
     $this->assertNotMount('{{TemporaryMountPointName#' . $shareData1['name'] . '}}');
     $this->assertNotMount('{{TemporaryMountPointName#' . $shareData1['name'] . '}}-1');
     $this->manager->removeUserShares($this->uid);
     $this->assertEmpty(\Test_Helper::invokePrivate($this->manager, 'getShares', [null]), 'Asserting all shares for the user have been deleted');
     $this->mountManager->clear();
     \Test_Helper::invokePrivate($this->manager, 'setupMounts');
     $this->assertNotMount($shareData1['name']);
     $this->assertNotMount('{{TemporaryMountPointName#' . $shareData1['name'] . '}}');
     $this->assertNotMount('{{TemporaryMountPointName#' . $shareData1['name'] . '}}-1');
 }
コード例 #8
0
ファイル: remote.php プロジェクト: kenwi/core
 /**
  * Unshare a remote share
  *
  * @param array $params contains the shareID 'id' which should be unshared
  * @return \OC_OCS_Result
  */
 public static function unshare($params)
 {
     $externalManager = new Manager(\OC::$server->getDatabaseConnection(), Filesystem::getMountManager(), Filesystem::getLoader(), \OC::$server->getHTTPHelper(), \OC::$server->getNotificationManager(), \OC_User::getUser());
     $shareInfo = $externalManager->getShare($params['id']);
     if ($shareInfo === false) {
         return new \OC_OCS_Result(null, 404, 'Share does not exist');
     }
     $mountPoint = '/' . \OC_User::getUser() . '/files' . $shareInfo['mountpoint'];
     if ($externalManager->removeShare($mountPoint) === true) {
         return new \OC_OCS_Result(null);
     } else {
         return new \OC_OCS_Result(null, 403, 'Could not unshare');
     }
 }
コード例 #9
0
 /**
  * @NoAdminRequired
  * @NoOutgoingFederatedSharingRequired
  *
  * @param $id
  * @return JSONResponse
  */
 public function destroy($id)
 {
     $this->externalManager->declineShare($id);
     return new JSONResponse();
 }
コード例 #10
0
ファイル: hooks.php プロジェクト: hyb148/core
 public static function deleteUser($params)
 {
     $manager = new External\Manager(\OC::$server->getDatabaseConnection(), \OC\Files\Filesystem::getMountManager(), \OC\Files\Filesystem::getLoader(), \OC::$server->getHTTPHelper(), \OC::$server->getNotificationManager(), $params['uid']);
     $manager->removeUserShares($params['uid']);
 }
コード例 #11
0
ファイル: Hooks.php プロジェクト: rchicoli/owncloud-core
 public static function deleteUser($params)
 {
     $discoveryManager = new DiscoveryManager(\OC::$server->getMemCacheFactory(), \OC::$server->getHTTPClientService());
     $manager = new External\Manager(\OC::$server->getDatabaseConnection(), \OC\Files\Filesystem::getMountManager(), \OC\Files\Filesystem::getLoader(), \OC::$server->getHTTPHelper(), \OC::$server->getNotificationManager(), $discoveryManager, $params['uid']);
     $manager->removeUserShares($params['uid']);
 }