summaryrefslogtreecommitdiffstats
path: root/apps/dav
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@owncloud.com>2016-01-26 21:19:44 +0100
committerArthur Schiwon <blizzz@owncloud.com>2016-01-26 21:35:12 +0100
commita5c528ff7e9bf6b7a9a35a8274b9e03a52153615 (patch)
tree05f9871a764d0f8a7b2d575464f55a33d18c3215 /apps/dav
parentdb788a382c94b86f62980bc41945b8ea6825f59e (diff)
downloadnextcloud-server-a5c528ff7e9bf6b7a9a35a8274b9e03a52153615.tar.gz
nextcloud-server-a5c528ff7e9bf6b7a9a35a8274b9e03a52153615.zip
provide info about plugin, and do not run commit ourselves on proppatch
Diffstat (limited to 'apps/dav')
-rw-r--r--apps/dav/lib/comments/commentnode.php1
-rw-r--r--apps/dav/lib/comments/commentsplugin.php15
-rw-r--r--apps/dav/tests/unit/comments/commentnode.php3
-rw-r--r--apps/dav/tests/unit/comments/commentsplugin.php25
4 files changed, 36 insertions, 8 deletions
diff --git a/apps/dav/lib/comments/commentnode.php b/apps/dav/lib/comments/commentnode.php
index 376c1bf3274..eb26e350a42 100644
--- a/apps/dav/lib/comments/commentnode.php
+++ b/apps/dav/lib/comments/commentnode.php
@@ -170,7 +170,6 @@ class CommentNode implements \Sabre\DAV\INode, \Sabre\DAV\IProperties {
function propPatch(PropPatch $propPatch) {
// other properties than 'message' are read only
$propPatch->handle('{'.self::NS_OWNCLOUD.'}message', [$this, 'updateComment']);
- $propPatch->commit();
}
/**
diff --git a/apps/dav/lib/comments/commentsplugin.php b/apps/dav/lib/comments/commentsplugin.php
index 2f9b7bab59f..7e227fd2914 100644
--- a/apps/dav/lib/comments/commentsplugin.php
+++ b/apps/dav/lib/comments/commentsplugin.php
@@ -43,6 +43,7 @@ class CommentsPlugin extends ServerPlugin {
// namespace
const NS_OWNCLOUD = 'http://owncloud.org/ns';
+ const REPORT_NAME = '{http://owncloud.org/ns}filter-comments';
const REPORT_PARAM_LIMIT = '{http://owncloud.org/ns}limit';
const REPORT_PARAM_OFFSET = '{http://owncloud.org/ns}offset';
const REPORT_PARAM_TIMESTAMP = '{http://owncloud.org/ns}datetime';
@@ -125,6 +126,18 @@ class CommentsPlugin extends ServerPlugin {
}
/**
+ * Returns a list of reports this plugin supports.
+ *
+ * This will be used in the {DAV:}supported-report-set property.
+ *
+ * @param string $uri
+ * @return array
+ */
+ public function getSupportedReportSet($uri) {
+ return [self::REPORT_NAME];
+ }
+
+ /**
* REPORT operations to look for comments
*
* @param string $reportName
@@ -136,7 +149,7 @@ class CommentsPlugin extends ServerPlugin {
*/
public function onReport($reportName, $report, $uri) {
$node = $this->server->tree->getNodeForPath($uri);
- if(!$node instanceof EntityCollection) {
+ if(!$node instanceof EntityCollection || $reportName !== self::REPORT_NAME) {
throw new ReportNotSupported();
}
$args = ['limit' => 0, 'offset' => 0, 'datetime' => null];
diff --git a/apps/dav/tests/unit/comments/commentnode.php b/apps/dav/tests/unit/comments/commentnode.php
index e1498459ce8..aa75e35d665 100644
--- a/apps/dav/tests/unit/comments/commentnode.php
+++ b/apps/dav/tests/unit/comments/commentnode.php
@@ -114,9 +114,6 @@ class CommentsNode extends \Test\TestCase {
->method('handle')
->with('{http://owncloud.org/ns}message');
- $propPatch->expects($this->once())
- ->method('commit');
-
$this->node->propPatch($propPatch);
}
diff --git a/apps/dav/tests/unit/comments/commentsplugin.php b/apps/dav/tests/unit/comments/commentsplugin.php
index 391c79d156a..bd0b56fc650 100644
--- a/apps/dav/tests/unit/comments/commentsplugin.php
+++ b/apps/dav/tests/unit/comments/commentsplugin.php
@@ -517,7 +517,26 @@ class CommentsPlugin extends \Test\TestCase {
->will($this->returnValue($path));
$this->plugin->initialize($this->server);
- $this->plugin->onReport('', [], '/' . $path);
+ $this->plugin->onReport(CommentsPluginImplementation::REPORT_NAME, [], '/' . $path);
+ }
+
+ /**
+ * @expectedException \Sabre\DAV\Exception\ReportNotSupported
+ */
+ public function testOnReportInvalidReportName() {
+ $path = 'comments/files/42';
+
+ $this->tree->expects($this->any())
+ ->method('getNodeForPath')
+ ->with('/' . $path)
+ ->will($this->returnValue($this->getMock('\Sabre\DAV\INode')));
+
+ $this->server->expects($this->any())
+ ->method('getRequestUri')
+ ->will($this->returnValue($path));
+ $this->plugin->initialize($this->server);
+
+ $this->plugin->onReport('{whoever}whatever', [], '/' . $path);
}
public function testOnReportDateTimeEmpty() {
@@ -572,7 +591,7 @@ class CommentsPlugin extends \Test\TestCase {
$this->server->httpResponse = $response;
$this->plugin->initialize($this->server);
- $this->plugin->onReport('', $parameters, '/' . $path);
+ $this->plugin->onReport(CommentsPluginImplementation::REPORT_NAME, $parameters, '/' . $path);
}
public function testOnReport() {
@@ -627,7 +646,7 @@ class CommentsPlugin extends \Test\TestCase {
$this->server->httpResponse = $response;
$this->plugin->initialize($this->server);
- $this->plugin->onReport('', $parameters, '/' . $path);
+ $this->plugin->onReport(CommentsPluginImplementation::REPORT_NAME, $parameters, '/' . $path);
}