aboutsummaryrefslogtreecommitdiffstats
path: root/lib/public/Files
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2017-03-08 13:09:19 +0100
committerGitHub <noreply@github.com>2017-03-08 13:09:19 +0100
commit2a8e922d67a1246e101f926f1b0ab287db71929e (patch)
treec3f67150e3e03386eedc6a23b1c2dcf657e4459b /lib/public/Files
parent74ac5dffbd07f9a7ac9a248eeafaa0f2852b5f79 (diff)
parenta3e638709b4702156a3ddc0791de1d6ce9fb902e (diff)
downloadnextcloud-server-2a8e922d67a1246e101f926f1b0ab287db71929e.tar.gz
nextcloud-server-2a8e922d67a1246e101f926f1b0ab287db71929e.zip
Merge pull request #3360 from nextcloud/dav-search
Implement webdav SEARCH
Diffstat (limited to 'lib/public/Files')
-rw-r--r--lib/public/Files/Cache/ICache.php12
-rw-r--r--lib/public/Files/Folder.php3
-rw-r--r--lib/public/Files/Search/ISearchBinaryOperator.php51
-rw-r--r--lib/public/Files/Search/ISearchComparison.php60
-rw-r--r--lib/public/Files/Search/ISearchOperator.php29
-rw-r--r--lib/public/Files/Search/ISearchOrder.php46
-rw-r--r--lib/public/Files/Search/ISearchQuery.php57
7 files changed, 257 insertions, 1 deletions
diff --git a/lib/public/Files/Cache/ICache.php b/lib/public/Files/Cache/ICache.php
index 7d01b1a2908..63993d0a8cb 100644
--- a/lib/public/Files/Cache/ICache.php
+++ b/lib/public/Files/Cache/ICache.php
@@ -21,6 +21,8 @@
*/
namespace OCP\Files\Cache;
+use OCP\Files\Search\ISearchOperator;
+use OCP\Files\Search\ISearchQuery;
/**
* Metadata cache for a storage
@@ -213,6 +215,16 @@ interface ICache {
public function searchByMime($mimetype);
/**
+ * Search for files with a flexible query
+ *
+ * @param ISearchQuery $query
+ * @return ICacheEntry[]
+ * @throw \InvalidArgumentException if the cache is unable to perform the query
+ * @since 12.0.0
+ */
+ public function searchQuery(ISearchQuery $query);
+
+ /**
* Search for files by tag of a given users.
*
* Note that every user can tag files differently.
diff --git a/lib/public/Files/Folder.php b/lib/public/Files/Folder.php
index 8f8576d8503..52a4b303196 100644
--- a/lib/public/Files/Folder.php
+++ b/lib/public/Files/Folder.php
@@ -30,6 +30,7 @@
// use OCP namespace for all classes that are considered public.
// This means that they should be used by apps instead of the internal ownCloud classes
namespace OCP\Files;
+use OCP\Files\Search\ISearchQuery;
/**
* @since 6.0.0
@@ -115,7 +116,7 @@ interface Folder extends Node {
/**
* search for files with the name matching $query
*
- * @param string $query
+ * @param string|ISearchQuery $query
* @return \OCP\Files\Node[]
* @since 6.0.0
*/
diff --git a/lib/public/Files/Search/ISearchBinaryOperator.php b/lib/public/Files/Search/ISearchBinaryOperator.php
new file mode 100644
index 00000000000..d5a2d5dc02d
--- /dev/null
+++ b/lib/public/Files/Search/ISearchBinaryOperator.php
@@ -0,0 +1,51 @@
+<?php
+/**
+ * @copyright Copyright (c) 2017 Robin Appelman <robin@icewind.nl>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCP\Files\Search;
+
+/**
+ * @since 12.0.0
+ */
+interface ISearchBinaryOperator extends ISearchOperator {
+ const OPERATOR_AND = 'and';
+ const OPERATOR_OR = 'or';
+ const OPERATOR_NOT = 'not';
+
+ /**
+ * The type of binary operator
+ *
+ * One of the ISearchBinaryOperator::OPERATOR_* constants
+ *
+ * @return string
+ * @since 12.0.0
+ */
+ public function getType();
+
+ /**
+ * The arguments for the binary operator
+ *
+ * One argument for the 'not' operator and two for 'and' and 'or'
+ *
+ * @return ISearchOperator[]
+ * @since 12.0.0
+ */
+ public function getArguments();
+}
diff --git a/lib/public/Files/Search/ISearchComparison.php b/lib/public/Files/Search/ISearchComparison.php
new file mode 100644
index 00000000000..5468260f001
--- /dev/null
+++ b/lib/public/Files/Search/ISearchComparison.php
@@ -0,0 +1,60 @@
+<?php
+/**
+ * @copyright Copyright (c) 2017 Robin Appelman <robin@icewind.nl>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCP\Files\Search;
+
+/**
+ * @since 12.0.0
+ */
+interface ISearchComparison extends ISearchOperator {
+ const COMPARE_EQUAL = 'eq';
+ const COMPARE_GREATER_THAN = 'gt';
+ const COMPARE_GREATER_THAN_EQUAL = 'gte';
+ const COMPARE_LESS_THAN = 'lt';
+ const COMPARE_LESS_THAN_EQUAL = 'lte';
+ const COMPARE_LIKE = 'like';
+
+ /**
+ * Get the type of comparison, one of the ISearchComparison::COMPARE_* constants
+ *
+ * @return string
+ * @since 12.0.0
+ */
+ public function getType();
+
+ /**
+ * Get the name of the field to compare with
+ *
+ * i.e. 'size', 'name' or 'mimetype'
+ *
+ * @return string
+ * @since 12.0.0
+ */
+ public function getField();
+
+ /**
+ * Get the value to compare the field with
+ *
+ * @return string|integer|\DateTime
+ * @since 12.0.0
+ */
+ public function getValue();
+}
diff --git a/lib/public/Files/Search/ISearchOperator.php b/lib/public/Files/Search/ISearchOperator.php
new file mode 100644
index 00000000000..047792bc782
--- /dev/null
+++ b/lib/public/Files/Search/ISearchOperator.php
@@ -0,0 +1,29 @@
+<?php
+/**
+ * @copyright Copyright (c) 2017 Robin Appelman <robin@icewind.nl>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCP\Files\Search;
+
+/**
+ * @since 12.0.0
+ */
+interface ISearchOperator {
+
+}
diff --git a/lib/public/Files/Search/ISearchOrder.php b/lib/public/Files/Search/ISearchOrder.php
new file mode 100644
index 00000000000..1abfd7506d5
--- /dev/null
+++ b/lib/public/Files/Search/ISearchOrder.php
@@ -0,0 +1,46 @@
+<?php
+/**
+ * @copyright Copyright (c) 2017 Robin Appelman <robin@icewind.nl>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCP\Files\Search;
+
+/**
+ * @since 12.0.0
+ */
+interface ISearchOrder {
+ const DIRECTION_ASCENDING = 'asc';
+ const DIRECTION_DESCENDING = 'desc';
+
+ /**
+ * The direction to sort in, either ISearchOrder::DIRECTION_ASCENDING or ISearchOrder::DIRECTION_DESCENDING
+ *
+ * @return string
+ * @since 12.0.0
+ */
+ public function getDirection();
+
+ /**
+ * The field to sort on
+ *
+ * @return string
+ * @since 12.0.0
+ */
+ public function getField();
+}
diff --git a/lib/public/Files/Search/ISearchQuery.php b/lib/public/Files/Search/ISearchQuery.php
new file mode 100644
index 00000000000..5a701b321b1
--- /dev/null
+++ b/lib/public/Files/Search/ISearchQuery.php
@@ -0,0 +1,57 @@
+<?php
+/**
+ * @copyright Copyright (c) 2017 Robin Appelman <robin@icewind.nl>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCP\Files\Search;
+
+/**
+ * @since 12.0.0
+ */
+interface ISearchQuery {
+ /**
+ * @return ISearchOperator
+ * @since 12.0.0
+ */
+ public function getSearchOperation();
+
+ /**
+ * Get the maximum number of results to return
+ *
+ * @return integer
+ * @since 12.0.0
+ */
+ public function getLimit();
+
+ /**
+ * Get the offset for returned results
+ *
+ * @return integer
+ * @since 12.0.0
+ */
+ public function getOffset();
+
+ /**
+ * The fields and directions to order by
+ *
+ * @return ISearchOrder[]
+ * @since 12.0.0
+ */
+ public function getOrder();
+}