* * @copyright Copyright (c) 2015, ownCloud, Inc. * @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 * */ namespace OCA\DAV\SystemTag; use Sabre\DAV\Exception\Forbidden; use Sabre\DAV\Exception\MethodNotAllowed; use Sabre\DAV\ICollection; use OCP\SystemTag\ISystemTagManager; use OCP\SystemTag\ISystemTagObjectMapper; /** * Collection containing object ids by object type */ class SystemTagsObjectTypeCollection implements ICollection { /** * @var string */ private $objectType; /** * @var ISystemTagManager */ private $tagManager; /** * @var ISystemTagObjectMapper */ private $tagMapper; /** * Constructor * * @param string $objectType object type * @param ISystemTagManager $tagManager * @param ISystemTagObjectMapper $tagMapper */ public function __construct($objectType, $tagManager, $tagMapper) { $this->tagManager = $tagManager; $this->tagMapper = $tagMapper; $this->objectType = $objectType; } function createFile($name, $data = null) { throw new Forbidden('Permission denied to create collections'); } function createDirectory($name) { throw new Forbidden('Permission denied to create collections'); } function getChild($objectId) { return new SystemTagsObjectMappingCollection( $objectId, $this->objectType, $this->tagManager, $this->tagMapper ); } function getChildren() { // do not list object ids throw new MethodNotAllowed(); } function childExists($name) { return true; } function delete() { throw new Forbidden('Permission denied to delete this collection'); } function getName() { return $this->objectType; } function setName($name) { throw new Forbidden('Permission denied to rename this collection'); } /** * Returns the last modification time, as a unix timestamp * * @return int */ function getLastModified() { return null; } }