\OC::$server->getUserSession(),
\OC::$server->getMountManager(),
\OC::$server->getTagManager(),
- \OC::$server->getRequest()
+ \OC::$server->getRequest(),
+ \OC::$server->getPreviewManager()
);
$requestUri = \OC::$server->getRequest()->getRequestUri();
\OC::$server->getUserSession(),
\OC::$server->getMountManager(),
\OC::$server->getTagManager(),
- \OC::$server->getRequest()
+ \OC::$server->getRequest(),
+ \OC::$server->getPreviewManager()
);
// Backends
use OC\Files\View;
use OCA\DAV\Upload\FutureFile;
use OCP\Files\ForbiddenException;
+use OCP\IPreview;
use Sabre\DAV\Exception\Forbidden;
use Sabre\DAV\Exception\NotFound;
use Sabre\DAV\IFile;
// namespace
const NS_OWNCLOUD = 'http://owncloud.org/ns';
+ const NS_NEXTCLOUD = 'http://nextcloud.org/ns';
const FILEID_PROPERTYNAME = '{http://owncloud.org/ns}id';
const INTERNAL_FILEID_PROPERTYNAME = '{http://owncloud.org/ns}fileid';
const PERMISSIONS_PROPERTYNAME = '{http://owncloud.org/ns}permissions';
const OWNER_DISPLAY_NAME_PROPERTYNAME = '{http://owncloud.org/ns}owner-display-name';
const CHECKSUMS_PROPERTYNAME = '{http://owncloud.org/ns}checksums';
const DATA_FINGERPRINT_PROPERTYNAME = '{http://owncloud.org/ns}data-fingerprint';
+ const HAS_PREVIEW_PROPERTYNAME = '{http://nextcloud.org/ns}has-preview';
/**
* Reference to main server object
*/
private $request;
+ /**
+ * @var IPreview
+ */
+ private $previewManager;
+
/**
* @param Tree $tree
* @param View $view
* @param IConfig $config
* @param IRequest $request
+ * @param IPreview $previewManager
* @param bool $isPublic
* @param bool $downloadAttachment
*/
View $view,
IConfig $config,
IRequest $request,
+ IPreview $previewManager,
$isPublic = false,
$downloadAttachment = true) {
$this->tree = $tree;
$this->request = $request;
$this->isPublic = $isPublic;
$this->downloadAttachment = $downloadAttachment;
+ $this->previewManager = $previewManager;
}
/**
public function initialize(\Sabre\DAV\Server $server) {
$server->xml->namespaceMap[self::NS_OWNCLOUD] = 'oc';
+ $server->xml->namespaceMap[self::NS_NEXTCLOUD] = 'nc';
$server->protectedProperties[] = self::FILEID_PROPERTYNAME;
$server->protectedProperties[] = self::INTERNAL_FILEID_PROPERTYNAME;
$server->protectedProperties[] = self::PERMISSIONS_PROPERTYNAME;
$server->protectedProperties[] = self::OWNER_DISPLAY_NAME_PROPERTYNAME;
$server->protectedProperties[] = self::CHECKSUMS_PROPERTYNAME;
$server->protectedProperties[] = self::DATA_FINGERPRINT_PROPERTYNAME;
+ $server->protectedProperties[] = self::HAS_PREVIEW_PROPERTYNAME;
// normally these cannot be changed (RFC4918), but we want them modifiable through PROPPATCH
$allowedProperties = ['{DAV:}getetag'];
return $this->config->getSystemValue('data-fingerprint', '');
}
});
+
+ $propFind->handle(self::HAS_PREVIEW_PROPERTYNAME, function () use ($node) {
+ return json_encode($this->previewManager->isAvailable($node->getFileInfo()));
+ });
}
if ($node instanceof \OCA\DAV\Files\FilesHome) {
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\ILogger;
+use OCP\IPreview;
use OCP\IRequest;
use OCP\ITagManager;
use OCP\IUserSession;
private $tagManager;
/** @var IRequest */
private $request;
+ /** @var IPreview */
+ private $previewManager;
/**
* @param IConfig $config
* @param IMountManager $mountManager
* @param ITagManager $tagManager
* @param IRequest $request
+ * @param IPreview $previewManager
*/
public function __construct(
IConfig $config,
IUserSession $userSession,
IMountManager $mountManager,
ITagManager $tagManager,
- IRequest $request
+ IRequest $request,
+ IPreview $previewManager
) {
$this->config = $config;
$this->logger = $logger;
$this->mountManager = $mountManager;
$this->tagManager = $tagManager;
$this->request = $request;
+ $this->previewManager = $previewManager;
}
/**
$view,
$this->config,
$this->request,
+ $this->previewManager,
false,
!$this->config->getSystemValue('debug', false)
)
$view,
\OC::$server->getConfig(),
$this->request,
+ \OC::$server->getPreviewManager(),
false,
!\OC::$server->getConfig()->getSystemValue('debug', false)
)
const OWNER_ID_PROPERTYNAME = FilesPlugin::OWNER_ID_PROPERTYNAME;
const OWNER_DISPLAY_NAME_PROPERTYNAME = FilesPlugin::OWNER_DISPLAY_NAME_PROPERTYNAME;
const DATA_FINGERPRINT_PROPERTYNAME = FilesPlugin::DATA_FINGERPRINT_PROPERTYNAME;
+ const HAS_PREVIEW_PROPERTYNAME = FilesPlugin::HAS_PREVIEW_PROPERTYNAME;
/**
* @var \Sabre\DAV\Server | \PHPUnit_Framework_MockObject_MockObject
*/
private $request;
+ /**
+ * @var \OCP\IPreview | \PHPUnit_Framework_MockObject_MockObject
+ */
+ private $previewManager;
+
public function setUp() {
parent::setUp();
$this->server = $this->getMockBuilder('\Sabre\DAV\Server')
$this->request = $this->getMockBuilder('\OCP\IRequest')
->disableOriginalConstructor()
->getMock();
+ $this->previewManager = $this->getMockBuilder('\OCP\IPreview')
+ ->disableOriginalConstructor()
+ ->getMock();
$this->plugin = new FilesPlugin(
$this->tree,
$this->view,
$this->config,
- $this->request
+ $this->request,
+ $this->previewManager
);
$this->plugin->initialize($this->server);
}
$node->expects($this->any())
->method('getDavPermissions')
->will($this->returnValue('DWCKMSR'));
+ $node->expects($this->any())
+ ->method('getFileInfo')
+ ->will($this->returnValue(
+ $this->getMockBuilder('\OCP\Files\FileInfo')
+ ->disableOriginalConstructor()
+ ->getMock()
+ ));
return $node;
}
$this->getMockBuilder('\OCP\IRequest')
->disableOriginalConstructor()
->getMock(),
+ $this->previewManager,
true);
$this->plugin->initialize($this->server);
$this->plugin->httpGet($request, $response);
}
+
+ public function testHasPreview() {
+ /** @var \OCA\DAV\Connector\Sabre\Directory | \PHPUnit_Framework_MockObject_MockObject $node */
+ $node = $this->createTestNode('\OCA\DAV\Connector\Sabre\Directory');
+
+ $propFind = new PropFind(
+ '/dummyPath',
+ array(
+ self::HAS_PREVIEW_PROPERTYNAME
+ ),
+ 0
+ );
+
+ $this->previewManager->expects($this->once())
+ ->method('isAvailable')
+ ->will($this->returnValue(false));
+
+ $this->plugin->handleGetProperties(
+ $propFind,
+ $node
+ );
+
+ $this->assertEquals("false", $propFind->get(self::HAS_PREVIEW_PROPERTYNAME));
+ }
}
namespace OCA\DAV\Tests\unit\Connector\Sabre;
use OCA\DAV\Connector\Sabre\FilesReportPlugin as FilesReportPluginImplementation;
+use OCP\IPreview;
use Sabre\DAV\Exception\NotFound;
use OCP\SystemTag\ISystemTagObjectMapper;
use OC\Files\View;
/** @var Folder|\PHPUnit_Framework_MockObject_MockObject **/
private $userFolder;
+ /** @var IPreview|\PHPUnit_Framework_MockObject_MockObject * */
+ private $previewManager;
+
public function setUp() {
parent::setUp();
$this->tree = $this->getMockBuilder('\Sabre\DAV\Tree')
->disableOriginalConstructor()
->getMock();
+ $this->previewManager = $this->getMockBuilder('\OCP\IPreview')
+ ->disableOriginalConstructor()
+ ->getMock();
+
$user = $this->getMockBuilder('\OCP\IUser')
->disableOriginalConstructor()
->getMock();
$config,
$this->getMockBuilder('\OCP\IRequest')
->disableOriginalConstructor()
- ->getMock()
+ ->getMock(),
+ $this->previewManager
)
);
$this->plugin->initialize($this->server);
\OC::$server->getTagManager(),
$this->getMockBuilder('\OCP\IRequest')
->disableOriginalConstructor()
- ->getMock()
+ ->getMock(),
+ \OC::$server->getPreviewManager()
);
}