summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@owncloud.com>2016-01-27 20:51:26 +0100
committerRoeland Jago Douma <rullzer@owncloud.com>2016-01-28 07:54:09 +0100
commit34e912ab6b7b95660bbbdf7cec4074b272ce5d1a (patch)
treedb87885f8cd928913f50070c2b13307052359327 /apps
parentf2e70441e42a17b27248b93a05b0008717b124b1 (diff)
downloadnextcloud-server-34e912ab6b7b95660bbbdf7cec4074b272ce5d1a.tar.gz
nextcloud-server-34e912ab6b7b95660bbbdf7cec4074b272ce5d1a.zip
[Share 2.0] Fix interfaces and comments
* Made comments more clear * Removed unneeded methods * IShares shareTime is now a proper DateTime object * IShares getPath -> getNode & setPath -> setNode * Fix unit tests
Diffstat (limited to 'apps')
-rw-r--r--apps/files_sharing/api/share20ocs.php22
-rw-r--r--apps/files_sharing/lib/controllers/sharecontroller.php30
-rw-r--r--apps/files_sharing/tests/api/share20ocstest.php13
-rw-r--r--apps/files_sharing/tests/controller/sharecontroller.php2
4 files changed, 34 insertions, 33 deletions
diff --git a/apps/files_sharing/api/share20ocs.php b/apps/files_sharing/api/share20ocs.php
index 8e216c8c3c8..8d481d817ea 100644
--- a/apps/files_sharing/api/share20ocs.php
+++ b/apps/files_sharing/api/share20ocs.php
@@ -81,26 +81,26 @@ class Share20OCS {
'uid_owner' => $share->getSharedBy()->getUID(),
'displayname_owner' => $share->getSharedBy()->getDisplayName(),
'permissions' => $share->getPermissions(),
- 'stime' => $share->getShareTime(),
- 'parent' => $share->getParent(),
+ 'stime' => $share->getShareTime()->getTimestamp(),
+ 'parent' => null,
'expiration' => null,
'token' => null,
'uid_file_owner' => $share->getShareOwner()->getUID(),
'displayname_file_owner' => $share->getShareOwner()->getDisplayName(),
];
- $path = $share->getPath();
- $result['path'] = $this->rootFolder->getUserFolder($share->getShareOwner()->getUID())->getRelativePath($path->getPath());
- if ($path instanceOf \OCP\Files\Folder) {
+ $node = $share->getNode();
+ $result['path'] = $this->rootFolder->getUserFolder($share->getShareOwner()->getUID())->getRelativePath($node->getPath());
+ if ($node instanceOf \OCP\Files\Folder) {
$result['item_type'] = 'folder';
} else {
$result['item_type'] = 'file';
}
- $result['storage_id'] = $path->getStorage()->getId();
- $result['storage'] = $path->getStorage()->getCache()->getNumericStorageId();
- $result['item_source'] = $path->getId();
- $result['file_source'] = $path->getId();
- $result['file_parent'] = $path->getParent()->getId();
+ $result['storage_id'] = $node->getStorage()->getId();
+ $result['storage'] = $node->getStorage()->getCache()->getNumericStorageId();
+ $result['item_source'] = $node->getId();
+ $result['file_source'] = $node->getId();
+ $result['file_parent'] = $node->getParent()->getId();
$result['file_target'] = $share->getTarget();
if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) {
@@ -220,7 +220,7 @@ class Share20OCS {
return new \OC_OCS_Result(null, 404, 'wrong path, file/folder doesn\'t exist');
}
- $share->setPath($path);
+ $share->setNode($path);
// Parse permissions (if available)
$permissions = $this->request->getParam('permissions', null);
diff --git a/apps/files_sharing/lib/controllers/sharecontroller.php b/apps/files_sharing/lib/controllers/sharecontroller.php
index 407207c0efc..9fec57edbdd 100644
--- a/apps/files_sharing/lib/controllers/sharecontroller.php
+++ b/apps/files_sharing/lib/controllers/sharecontroller.php
@@ -214,14 +214,14 @@ class ShareController extends Controller {
}
// We can't get the path of a file share
- if ($share->getPath() instanceof \OCP\Files\File && $path !== '') {
+ if ($share->getNode() instanceof \OCP\Files\File && $path !== '') {
throw new NotFoundException();
}
$rootFolder = null;
- if ($share->getPath() instanceof \OCP\Files\Folder) {
+ if ($share->getNode() instanceof \OCP\Files\Folder) {
/** @var \OCP\Files\Folder $rootFolder */
- $rootFolder = $share->getPath();
+ $rootFolder = $share->getNode();
try {
$path = $rootFolder->get($path);
@@ -233,26 +233,26 @@ class ShareController extends Controller {
$shareTmpl = [];
$shareTmpl['displayName'] = $share->getShareOwner()->getDisplayName();
$shareTmpl['owner'] = $share->getShareOwner()->getUID();
- $shareTmpl['filename'] = $share->getPath()->getName();
+ $shareTmpl['filename'] = $share->getNode()->getName();
$shareTmpl['directory_path'] = $share->getTarget();
- $shareTmpl['mimetype'] = $share->getPath()->getMimetype();
- $shareTmpl['previewSupported'] = $this->previewManager->isMimeSupported($share->getPath()->getMimetype());
+ $shareTmpl['mimetype'] = $share->getNode()->getMimetype();
+ $shareTmpl['previewSupported'] = $this->previewManager->isMimeSupported($share->getNode()->getMimetype());
$shareTmpl['dirToken'] = $token;
$shareTmpl['sharingToken'] = $token;
$shareTmpl['server2serversharing'] = Helper::isOutgoingServer2serverShareEnabled();
$shareTmpl['protected'] = $share->getPassword() !== null ? 'true' : 'false';
$shareTmpl['dir'] = '';
- $shareTmpl['nonHumanFileSize'] = $share->getPath()->getSize();
- $shareTmpl['fileSize'] = \OCP\Util::humanFileSize($share->getPath()->getSize());
+ $shareTmpl['nonHumanFileSize'] = $share->getNode()->getSize();
+ $shareTmpl['fileSize'] = \OCP\Util::humanFileSize($share->getNode()->getSize());
// Show file list
- if ($share->getPath() instanceof \OCP\Files\Folder) {
+ if ($share->getNode() instanceof \OCP\Files\Folder) {
$shareTmpl['dir'] = $rootFolder->getRelativePath($path->getPath());
/*
* The OC_Util methods require a view. This just uses the node API
*/
- $freeSpace = $share->getPath()->getStorage()->free_space($share->getPath()->getInternalPath());
+ $freeSpace = $share->getNode()->getStorage()->free_space($share->getNode()->getInternalPath());
if ($freeSpace !== \OCP\Files\FileInfo::SPACE_UNKNOWN) {
$freeSpace = max($freeSpace, 0);
} else {
@@ -320,23 +320,23 @@ class ShareController extends Controller {
}
$userFolder = $this->rootFolder->getUserFolder($share->getShareOwner()->getUID());
- $originalSharePath = $userFolder->getRelativePath($share->getPath()->getPath());
+ $originalSharePath = $userFolder->getRelativePath($share->getNode()->getPath());
// Single file share
- if ($share->getPath() instanceof \OCP\Files\File) {
+ if ($share->getNode() instanceof \OCP\Files\File) {
// Single file download
$event = $this->activityManager->generateEvent();
$event->setApp('files_sharing')
->setType(Activity::TYPE_PUBLIC_LINKS)
- ->setSubject(Activity::SUBJECT_PUBLIC_SHARED_FILE_DOWNLOADED, [$userFolder->getRelativePath($share->getPath()->getPath())])
+ ->setSubject(Activity::SUBJECT_PUBLIC_SHARED_FILE_DOWNLOADED, [$userFolder->getRelativePath($share->getNode()->getPath())])
->setAffectedUser($share->getShareOwner()->getUID())
- ->setObject('files', $share->getPath()->getId(), $userFolder->getRelativePath($share->getPath()->getPath()));
+ ->setObject('files', $share->getNode()->getId(), $userFolder->getRelativePath($share->getNode()->getPath()));
$this->activityManager->publish($event);
}
// Directory share
else {
/** @var \OCP\Files\Folder $node */
- $node = $share->getPath();
+ $node = $share->getNode();
// Try to get the path
if ($path !== '') {
diff --git a/apps/files_sharing/tests/api/share20ocstest.php b/apps/files_sharing/tests/api/share20ocstest.php
index ebacf6c20fe..934a1cd19d2 100644
--- a/apps/files_sharing/tests/api/share20ocstest.php
+++ b/apps/files_sharing/tests/api/share20ocstest.php
@@ -148,11 +148,12 @@ class Share20OCSTest extends \Test\TestCase {
$share->method('getSharedWith')->willReturn($sharedWith);
$share->method('getSharedBy')->willReturn($sharedBy);
$share->method('getShareOwner')->willReturn($shareOwner);
- $share->method('getPath')->willReturn($path);
+ $share->method('getNode')->willReturn($path);
$share->method('getPermissions')->willReturn($permissions);
- $share->method('getShareTime')->willReturn($shareTime);
+ $time = new \DateTime();
+ $time->setTimestamp($shareTime);
+ $share->method('getShareTime')->willReturn($time);
$share->method('getExpirationDate')->willReturn($expiration);
- $share->method('getParent')->willReturn($parent);
$share->method('getTarget')->willReturn($target);
$share->method('getMailSend')->willReturn($mail_send);
$share->method('getToken')->willReturn($token);
@@ -242,7 +243,7 @@ class Share20OCSTest extends \Test\TestCase {
'expiration' => null,
'permissions' => 4,
'stime' => 5,
- 'parent' => 6,
+ 'parent' => null,
'storage_id' => 'STORAGE',
'path' => 'file',
'storage' => 101,
@@ -283,7 +284,7 @@ class Share20OCSTest extends \Test\TestCase {
'expiration' => null,
'permissions' => 4,
'stime' => 5,
- 'parent' => 6,
+ 'parent' => null,
'storage_id' => 'STORAGE',
'path' => 'folder',
'storage' => 101,
@@ -327,7 +328,7 @@ class Share20OCSTest extends \Test\TestCase {
'expiration' => '2000-01-02 00:00:00',
'permissions' => 4,
'stime' => 5,
- 'parent' => 6,
+ 'parent' => null,
'storage_id' => 'STORAGE',
'path' => 'folder',
'storage' => 101,
diff --git a/apps/files_sharing/tests/controller/sharecontroller.php b/apps/files_sharing/tests/controller/sharecontroller.php
index 7d13753d322..9f1d38f9f23 100644
--- a/apps/files_sharing/tests/controller/sharecontroller.php
+++ b/apps/files_sharing/tests/controller/sharecontroller.php
@@ -287,7 +287,7 @@ class ShareControllerTest extends \Test\TestCase {
$share->method('getId')->willReturn('42');
$share->method('getPassword')->willReturn('password');
$share->method('getShareOwner')->willReturn($owner);
- $share->method('getPath')->willReturn($file);
+ $share->method('getNode')->willReturn($file);
$share->method('getTarget')->willReturn('/file1.txt');
$this->session->method('exists')->with('public_link_authenticated')->willReturn(true);