aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Share20/Share.php
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@owncloud.com>2016-03-23 14:08:40 +0100
committerRoeland Jago Douma <rullzer@owncloud.com>2016-03-30 22:55:03 +0200
commit2f4294e7819c5cb298407b7e6101fd4f076969f9 (patch)
tree675f24310b6b9417faf002b342e9d39af21e02ad /lib/private/Share20/Share.php
parent00c9974d945f7d50d7d10d7de5fc5a16f4d7421e (diff)
downloadnextcloud-server-2f4294e7819c5cb298407b7e6101fd4f076969f9.tar.gz
nextcloud-server-2f4294e7819c5cb298407b7e6101fd4f076969f9.zip
Add setId and setProviderID to the public interface
Fixes #23337 We only allow the id to be set once!
Diffstat (limited to 'lib/private/Share20/Share.php')
-rw-r--r--lib/private/Share20/Share.php25
1 files changed, 23 insertions, 2 deletions
diff --git a/lib/private/Share20/Share.php b/lib/private/Share20/Share.php
index 6edd0e6886a..c361f01216f 100644
--- a/lib/private/Share20/Share.php
+++ b/lib/private/Share20/Share.php
@@ -26,6 +26,7 @@ use OCP\Files\Node;
use OCP\Files\NotFoundException;
use OCP\IUser;
use OCP\IGroup;
+use OCP\Share\Exceptions\IllegalIDChangeException;
class Share implements \OCP\Share\IShare {
@@ -75,7 +76,19 @@ class Share implements \OCP\Share\IShare {
* @inheritdoc
*/
public function setId($id) {
- $this->id = $id;
+ if (is_int($id)) {
+ $id = (string)$id;
+ }
+
+ if(!is_string($id)) {
+ throw new \InvalidArgumentException('String expected.');
+ }
+
+ if ($this->id !== null) {
+ throw new IllegalIDChangeException('Not allowed to assign a new internal id to a share');
+ }
+
+ $this->id = trim($id);
return $this;
}
@@ -100,7 +113,15 @@ class Share implements \OCP\Share\IShare {
* @inheritdoc
*/
public function setProviderId($id) {
- $this->providerId = $id;
+ if(!is_string($id)) {
+ throw new \InvalidArgumentException('String expected.');
+ }
+
+ if ($this->providerId !== null) {
+ throw new IllegalIDChangeException('Not allowed to assign a new provider id to a share');
+ }
+
+ $this->providerId = trim($id);
return $this;
}