-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29207 from owncloud/feature/29087
Adding meta data file tree to node api
- Loading branch information
Showing
27 changed files
with
1,931 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<?php | ||
/** | ||
* @author Thomas Müller <[email protected]> | ||
* | ||
* @copyright Copyright (c) 2017, ownCloud GmbH | ||
* @license AGPL-3.0 | ||
* | ||
* This code is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License, version 3, | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License, version 3, | ||
* along with this program. If not, see <http://www.gnu.org/licenses/> | ||
* | ||
*/ | ||
|
||
|
||
namespace OCA\DAV\Meta; | ||
|
||
|
||
use Sabre\DAV\File; | ||
|
||
class MetaFile extends File { | ||
|
||
/** @var \OCP\Files\File */ | ||
private $file; | ||
|
||
/** | ||
* MetaFolder constructor. | ||
* | ||
* @param \OCP\Files\File $file | ||
*/ | ||
public function __construct(\OCP\Files\File $file) { | ||
$this->file = $file; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
function getName() { | ||
return $this->file->getName(); | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
function getSize() { | ||
return $this->file->getSize(); | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function get() { | ||
return $this->file->fopen('r'); | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function getContentType() { | ||
return $this->file->getMimeType(); | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function getLastModified() { | ||
return $this->file->getMTime(); | ||
} | ||
|
||
public function getETag() { | ||
return $this->file->getEtag(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?php | ||
/** | ||
* @author Thomas Müller <[email protected]> | ||
* | ||
* @copyright Copyright (c) 2017, ownCloud GmbH | ||
* @license AGPL-3.0 | ||
* | ||
* This code is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License, version 3, | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License, version 3, | ||
* along with this program. If not, see <http://www.gnu.org/licenses/> | ||
* | ||
*/ | ||
|
||
|
||
namespace OCA\DAV\Meta; | ||
|
||
|
||
use OCP\Files\File; | ||
use OCP\Files\Folder; | ||
use OCP\Files\Node; | ||
use Sabre\DAV\Collection; | ||
|
||
class MetaFolder extends Collection { | ||
|
||
/** @var Folder */ | ||
private $folder; | ||
|
||
/** | ||
* MetaFolder constructor. | ||
* | ||
* @param Folder $folder | ||
*/ | ||
public function __construct(Folder $folder) { | ||
$this->folder = $folder; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
function getChildren() { | ||
$nodes = $this->folder->getDirectoryListing(); | ||
return array_map(function($node) { | ||
return static::nodeFactory($node); | ||
}, $nodes); | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
function getName() { | ||
return $this->folder->getName(); | ||
} | ||
|
||
public static function nodeFactory(Node $node) { | ||
if ($node instanceof Folder) { | ||
return new MetaFolder($node); | ||
} | ||
if ($node instanceof File) { | ||
return new MetaFile($node); | ||
} | ||
throw new \InvalidArgumentException(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
/** | ||
* @author Thomas Müller <[email protected]> | ||
* | ||
* @copyright Copyright (c) 2017, ownCloud GmbH | ||
* @license AGPL-3.0 | ||
* | ||
* This code is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License, version 3, | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License, version 3, | ||
* along with this program. If not, see <http://www.gnu.org/licenses/> | ||
* | ||
*/ | ||
|
||
|
||
namespace OCA\DAV\Meta; | ||
|
||
|
||
use OCP\Files\File; | ||
use OCP\Files\Folder; | ||
use OCP\Files\IRootFolder; | ||
use OCP\Files\Node; | ||
use OCP\Files\NotFoundException; | ||
use Sabre\DAV\Collection; | ||
use Sabre\DAV\Exception\MethodNotAllowed; | ||
use Sabre\DAV\Exception\NotFound; | ||
|
||
class RootCollection extends Collection { | ||
|
||
/** @var IRootFolder */ | ||
private $rootFolder; | ||
|
||
/** | ||
* RootCollection constructor. | ||
* | ||
* @param IRootFolder $rootFolder | ||
*/ | ||
public function __construct(IRootFolder $rootFolder) { | ||
$this->rootFolder = $rootFolder; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function getChild($name) { | ||
try { | ||
$child = $this->rootFolder->get("meta/$name"); | ||
return MetaFolder::nodeFactory($child); | ||
} catch (NotFoundException $ex) { | ||
throw new NotFound(); | ||
} | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
function getChildren() { | ||
throw new MethodNotAllowed('Listing members of this collection is disabled'); | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
function getName() { | ||
return 'meta'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.