@@ -28,56 +28,56 @@ |
||
28 | 28 | use OCP\Diagnostics\IEventLogger; |
29 | 29 | |
30 | 30 | class EventLogger implements IEventLogger { |
31 | - /** |
|
32 | - * @var \OC\Diagnostics\Event[] |
|
33 | - */ |
|
34 | - private $events = []; |
|
31 | + /** |
|
32 | + * @var \OC\Diagnostics\Event[] |
|
33 | + */ |
|
34 | + private $events = []; |
|
35 | 35 | |
36 | - /** |
|
37 | - * @var bool - Module needs to be activated by some app |
|
38 | - */ |
|
39 | - private $activated = false; |
|
36 | + /** |
|
37 | + * @var bool - Module needs to be activated by some app |
|
38 | + */ |
|
39 | + private $activated = false; |
|
40 | 40 | |
41 | - /** |
|
42 | - * @inheritdoc |
|
43 | - */ |
|
44 | - public function start($id, $description) { |
|
45 | - if ($this->activated) { |
|
46 | - $this->events[$id] = new Event($id, $description, microtime(true)); |
|
47 | - } |
|
48 | - } |
|
41 | + /** |
|
42 | + * @inheritdoc |
|
43 | + */ |
|
44 | + public function start($id, $description) { |
|
45 | + if ($this->activated) { |
|
46 | + $this->events[$id] = new Event($id, $description, microtime(true)); |
|
47 | + } |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * @inheritdoc |
|
52 | - */ |
|
53 | - public function end($id) { |
|
54 | - if ($this->activated && isset($this->events[$id])) { |
|
55 | - $timing = $this->events[$id]; |
|
56 | - $timing->end(microtime(true)); |
|
57 | - } |
|
58 | - } |
|
50 | + /** |
|
51 | + * @inheritdoc |
|
52 | + */ |
|
53 | + public function end($id) { |
|
54 | + if ($this->activated && isset($this->events[$id])) { |
|
55 | + $timing = $this->events[$id]; |
|
56 | + $timing->end(microtime(true)); |
|
57 | + } |
|
58 | + } |
|
59 | 59 | |
60 | - /** |
|
61 | - * @inheritdoc |
|
62 | - */ |
|
63 | - public function log($id, $description, $start, $end) { |
|
64 | - if ($this->activated) { |
|
65 | - $this->events[$id] = new Event($id, $description, $start); |
|
66 | - $this->events[$id]->end($end); |
|
67 | - } |
|
68 | - } |
|
60 | + /** |
|
61 | + * @inheritdoc |
|
62 | + */ |
|
63 | + public function log($id, $description, $start, $end) { |
|
64 | + if ($this->activated) { |
|
65 | + $this->events[$id] = new Event($id, $description, $start); |
|
66 | + $this->events[$id]->end($end); |
|
67 | + } |
|
68 | + } |
|
69 | 69 | |
70 | - /** |
|
71 | - * @inheritdoc |
|
72 | - */ |
|
73 | - public function getEvents() { |
|
74 | - return $this->events; |
|
75 | - } |
|
70 | + /** |
|
71 | + * @inheritdoc |
|
72 | + */ |
|
73 | + public function getEvents() { |
|
74 | + return $this->events; |
|
75 | + } |
|
76 | 76 | |
77 | - /** |
|
78 | - * @inheritdoc |
|
79 | - */ |
|
80 | - public function activate() { |
|
81 | - $this->activated = true; |
|
82 | - } |
|
77 | + /** |
|
78 | + * @inheritdoc |
|
79 | + */ |
|
80 | + public function activate() { |
|
81 | + $this->activated = true; |
|
82 | + } |
|
83 | 83 | } |
@@ -30,66 +30,66 @@ |
||
30 | 30 | * Uses a simple FIFO expiry mechanism |
31 | 31 | */ |
32 | 32 | class CappedMemoryCache implements ICache, \ArrayAccess { |
33 | - private $capacity; |
|
34 | - private $cache = []; |
|
35 | - |
|
36 | - public function __construct($capacity = 512) { |
|
37 | - $this->capacity = $capacity; |
|
38 | - } |
|
39 | - |
|
40 | - public function hasKey($key) { |
|
41 | - return isset($this->cache[$key]); |
|
42 | - } |
|
43 | - |
|
44 | - public function get($key) { |
|
45 | - return isset($this->cache[$key]) ? $this->cache[$key] : null; |
|
46 | - } |
|
47 | - |
|
48 | - public function set($key, $value, $ttl = 0) { |
|
49 | - if (is_null($key)) { |
|
50 | - $this->cache[] = $value; |
|
51 | - } else { |
|
52 | - $this->cache[$key] = $value; |
|
53 | - } |
|
54 | - $this->garbageCollect(); |
|
55 | - } |
|
56 | - |
|
57 | - public function remove($key) { |
|
58 | - unset($this->cache[$key]); |
|
59 | - return true; |
|
60 | - } |
|
61 | - |
|
62 | - public function clear($prefix = '') { |
|
63 | - $this->cache = []; |
|
64 | - return true; |
|
65 | - } |
|
66 | - |
|
67 | - public function offsetExists($offset) { |
|
68 | - return $this->hasKey($offset); |
|
69 | - } |
|
70 | - |
|
71 | - public function &offsetGet($offset) { |
|
72 | - return $this->cache[$offset]; |
|
73 | - } |
|
74 | - |
|
75 | - public function offsetSet($offset, $value) { |
|
76 | - $this->set($offset, $value); |
|
77 | - } |
|
78 | - |
|
79 | - public function offsetUnset($offset) { |
|
80 | - $this->remove($offset); |
|
81 | - } |
|
82 | - |
|
83 | - public function getData() { |
|
84 | - return $this->cache; |
|
85 | - } |
|
86 | - |
|
87 | - |
|
88 | - private function garbageCollect() { |
|
89 | - while (count($this->cache) > $this->capacity) { |
|
90 | - reset($this->cache); |
|
91 | - $key = key($this->cache); |
|
92 | - $this->remove($key); |
|
93 | - } |
|
94 | - } |
|
33 | + private $capacity; |
|
34 | + private $cache = []; |
|
35 | + |
|
36 | + public function __construct($capacity = 512) { |
|
37 | + $this->capacity = $capacity; |
|
38 | + } |
|
39 | + |
|
40 | + public function hasKey($key) { |
|
41 | + return isset($this->cache[$key]); |
|
42 | + } |
|
43 | + |
|
44 | + public function get($key) { |
|
45 | + return isset($this->cache[$key]) ? $this->cache[$key] : null; |
|
46 | + } |
|
47 | + |
|
48 | + public function set($key, $value, $ttl = 0) { |
|
49 | + if (is_null($key)) { |
|
50 | + $this->cache[] = $value; |
|
51 | + } else { |
|
52 | + $this->cache[$key] = $value; |
|
53 | + } |
|
54 | + $this->garbageCollect(); |
|
55 | + } |
|
56 | + |
|
57 | + public function remove($key) { |
|
58 | + unset($this->cache[$key]); |
|
59 | + return true; |
|
60 | + } |
|
61 | + |
|
62 | + public function clear($prefix = '') { |
|
63 | + $this->cache = []; |
|
64 | + return true; |
|
65 | + } |
|
66 | + |
|
67 | + public function offsetExists($offset) { |
|
68 | + return $this->hasKey($offset); |
|
69 | + } |
|
70 | + |
|
71 | + public function &offsetGet($offset) { |
|
72 | + return $this->cache[$offset]; |
|
73 | + } |
|
74 | + |
|
75 | + public function offsetSet($offset, $value) { |
|
76 | + $this->set($offset, $value); |
|
77 | + } |
|
78 | + |
|
79 | + public function offsetUnset($offset) { |
|
80 | + $this->remove($offset); |
|
81 | + } |
|
82 | + |
|
83 | + public function getData() { |
|
84 | + return $this->cache; |
|
85 | + } |
|
86 | + |
|
87 | + |
|
88 | + private function garbageCollect() { |
|
89 | + while (count($this->cache) > $this->capacity) { |
|
90 | + reset($this->cache); |
|
91 | + $key = key($this->cache); |
|
92 | + $this->remove($key); |
|
93 | + } |
|
94 | + } |
|
95 | 95 | } |
@@ -27,104 +27,104 @@ |
||
27 | 27 | use OCP\ICertificate; |
28 | 28 | |
29 | 29 | class Certificate implements ICertificate { |
30 | - protected $name; |
|
31 | - |
|
32 | - protected $commonName; |
|
33 | - |
|
34 | - protected $organization; |
|
35 | - |
|
36 | - protected $serial; |
|
37 | - |
|
38 | - protected $issueDate; |
|
39 | - |
|
40 | - protected $expireDate; |
|
41 | - |
|
42 | - protected $issuerName; |
|
43 | - |
|
44 | - protected $issuerOrganization; |
|
45 | - |
|
46 | - /** |
|
47 | - * @param string $data base64 encoded certificate |
|
48 | - * @param string $name |
|
49 | - * @throws \Exception If the certificate could not get parsed |
|
50 | - */ |
|
51 | - public function __construct($data, $name) { |
|
52 | - $this->name = $name; |
|
53 | - $gmt = new \DateTimeZone('GMT'); |
|
54 | - |
|
55 | - // If string starts with "file://" ignore the certificate |
|
56 | - $query = 'file://'; |
|
57 | - if (strtolower(substr($data, 0, strlen($query))) === $query) { |
|
58 | - throw new \Exception('Certificate could not get parsed.'); |
|
59 | - } |
|
60 | - |
|
61 | - $info = openssl_x509_parse($data); |
|
62 | - if (!is_array($info)) { |
|
63 | - throw new \Exception('Certificate could not get parsed.'); |
|
64 | - } |
|
65 | - |
|
66 | - $this->commonName = isset($info['subject']['CN']) ? $info['subject']['CN'] : null; |
|
67 | - $this->organization = isset($info['subject']['O']) ? $info['subject']['O'] : null; |
|
68 | - $this->issueDate = new \DateTime('@' . $info['validFrom_time_t'], $gmt); |
|
69 | - $this->expireDate = new \DateTime('@' . $info['validTo_time_t'], $gmt); |
|
70 | - $this->issuerName = isset($info['issuer']['CN']) ? $info['issuer']['CN'] : null; |
|
71 | - $this->issuerOrganization = isset($info['issuer']['O']) ? $info['issuer']['O'] : null; |
|
72 | - } |
|
73 | - |
|
74 | - /** |
|
75 | - * @return string |
|
76 | - */ |
|
77 | - public function getName() { |
|
78 | - return $this->name; |
|
79 | - } |
|
80 | - |
|
81 | - /** |
|
82 | - * @return string|null |
|
83 | - */ |
|
84 | - public function getCommonName() { |
|
85 | - return $this->commonName; |
|
86 | - } |
|
87 | - |
|
88 | - /** |
|
89 | - * @return string |
|
90 | - */ |
|
91 | - public function getOrganization() { |
|
92 | - return $this->organization; |
|
93 | - } |
|
94 | - |
|
95 | - /** |
|
96 | - * @return \DateTime |
|
97 | - */ |
|
98 | - public function getIssueDate() { |
|
99 | - return $this->issueDate; |
|
100 | - } |
|
101 | - |
|
102 | - /** |
|
103 | - * @return \DateTime |
|
104 | - */ |
|
105 | - public function getExpireDate() { |
|
106 | - return $this->expireDate; |
|
107 | - } |
|
108 | - |
|
109 | - /** |
|
110 | - * @return bool |
|
111 | - */ |
|
112 | - public function isExpired() { |
|
113 | - $now = new \DateTime(); |
|
114 | - return $this->issueDate > $now or $now > $this->expireDate; |
|
115 | - } |
|
116 | - |
|
117 | - /** |
|
118 | - * @return string|null |
|
119 | - */ |
|
120 | - public function getIssuerName() { |
|
121 | - return $this->issuerName; |
|
122 | - } |
|
123 | - |
|
124 | - /** |
|
125 | - * @return string|null |
|
126 | - */ |
|
127 | - public function getIssuerOrganization() { |
|
128 | - return $this->issuerOrganization; |
|
129 | - } |
|
30 | + protected $name; |
|
31 | + |
|
32 | + protected $commonName; |
|
33 | + |
|
34 | + protected $organization; |
|
35 | + |
|
36 | + protected $serial; |
|
37 | + |
|
38 | + protected $issueDate; |
|
39 | + |
|
40 | + protected $expireDate; |
|
41 | + |
|
42 | + protected $issuerName; |
|
43 | + |
|
44 | + protected $issuerOrganization; |
|
45 | + |
|
46 | + /** |
|
47 | + * @param string $data base64 encoded certificate |
|
48 | + * @param string $name |
|
49 | + * @throws \Exception If the certificate could not get parsed |
|
50 | + */ |
|
51 | + public function __construct($data, $name) { |
|
52 | + $this->name = $name; |
|
53 | + $gmt = new \DateTimeZone('GMT'); |
|
54 | + |
|
55 | + // If string starts with "file://" ignore the certificate |
|
56 | + $query = 'file://'; |
|
57 | + if (strtolower(substr($data, 0, strlen($query))) === $query) { |
|
58 | + throw new \Exception('Certificate could not get parsed.'); |
|
59 | + } |
|
60 | + |
|
61 | + $info = openssl_x509_parse($data); |
|
62 | + if (!is_array($info)) { |
|
63 | + throw new \Exception('Certificate could not get parsed.'); |
|
64 | + } |
|
65 | + |
|
66 | + $this->commonName = isset($info['subject']['CN']) ? $info['subject']['CN'] : null; |
|
67 | + $this->organization = isset($info['subject']['O']) ? $info['subject']['O'] : null; |
|
68 | + $this->issueDate = new \DateTime('@' . $info['validFrom_time_t'], $gmt); |
|
69 | + $this->expireDate = new \DateTime('@' . $info['validTo_time_t'], $gmt); |
|
70 | + $this->issuerName = isset($info['issuer']['CN']) ? $info['issuer']['CN'] : null; |
|
71 | + $this->issuerOrganization = isset($info['issuer']['O']) ? $info['issuer']['O'] : null; |
|
72 | + } |
|
73 | + |
|
74 | + /** |
|
75 | + * @return string |
|
76 | + */ |
|
77 | + public function getName() { |
|
78 | + return $this->name; |
|
79 | + } |
|
80 | + |
|
81 | + /** |
|
82 | + * @return string|null |
|
83 | + */ |
|
84 | + public function getCommonName() { |
|
85 | + return $this->commonName; |
|
86 | + } |
|
87 | + |
|
88 | + /** |
|
89 | + * @return string |
|
90 | + */ |
|
91 | + public function getOrganization() { |
|
92 | + return $this->organization; |
|
93 | + } |
|
94 | + |
|
95 | + /** |
|
96 | + * @return \DateTime |
|
97 | + */ |
|
98 | + public function getIssueDate() { |
|
99 | + return $this->issueDate; |
|
100 | + } |
|
101 | + |
|
102 | + /** |
|
103 | + * @return \DateTime |
|
104 | + */ |
|
105 | + public function getExpireDate() { |
|
106 | + return $this->expireDate; |
|
107 | + } |
|
108 | + |
|
109 | + /** |
|
110 | + * @return bool |
|
111 | + */ |
|
112 | + public function isExpired() { |
|
113 | + $now = new \DateTime(); |
|
114 | + return $this->issueDate > $now or $now > $this->expireDate; |
|
115 | + } |
|
116 | + |
|
117 | + /** |
|
118 | + * @return string|null |
|
119 | + */ |
|
120 | + public function getIssuerName() { |
|
121 | + return $this->issuerName; |
|
122 | + } |
|
123 | + |
|
124 | + /** |
|
125 | + * @return string|null |
|
126 | + */ |
|
127 | + public function getIssuerOrganization() { |
|
128 | + return $this->issuerOrganization; |
|
129 | + } |
|
130 | 130 | } |
@@ -27,7 +27,7 @@ |
||
27 | 27 | use OCP\Encryption\Exceptions\GenericEncryptionException; |
28 | 28 | |
29 | 29 | class EncryptionHeaderToLargeException extends GenericEncryptionException { |
30 | - public function __construct() { |
|
31 | - parent::__construct('max header size exceeded'); |
|
32 | - } |
|
30 | + public function __construct() { |
|
31 | + parent::__construct('max header size exceeded'); |
|
32 | + } |
|
33 | 33 | } |
@@ -36,54 +36,54 @@ |
||
36 | 36 | * @method void setName(string $name) |
37 | 37 | */ |
38 | 38 | class Tag extends Entity { |
39 | - protected $owner; |
|
40 | - protected $type; |
|
41 | - protected $name; |
|
39 | + protected $owner; |
|
40 | + protected $type; |
|
41 | + protected $name; |
|
42 | 42 | |
43 | - /** |
|
44 | - * Constructor. |
|
45 | - * |
|
46 | - * @param string $owner The tag's owner |
|
47 | - * @param string $type The type of item this tag is used for |
|
48 | - * @param string $name The tag's name |
|
49 | - */ |
|
50 | - public function __construct($owner = null, $type = null, $name = null) { |
|
51 | - $this->setOwner($owner); |
|
52 | - $this->setType($type); |
|
53 | - $this->setName($name); |
|
54 | - } |
|
43 | + /** |
|
44 | + * Constructor. |
|
45 | + * |
|
46 | + * @param string $owner The tag's owner |
|
47 | + * @param string $type The type of item this tag is used for |
|
48 | + * @param string $name The tag's name |
|
49 | + */ |
|
50 | + public function __construct($owner = null, $type = null, $name = null) { |
|
51 | + $this->setOwner($owner); |
|
52 | + $this->setType($type); |
|
53 | + $this->setName($name); |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * Transform a database columnname to a property |
|
58 | - * |
|
59 | - * @param string $columnName the name of the column |
|
60 | - * @return string the property name |
|
61 | - * @todo migrate existing database columns to the correct names |
|
62 | - * to be able to drop this direct mapping |
|
63 | - */ |
|
64 | - public function columnToProperty($columnName) { |
|
65 | - if ($columnName === 'category') { |
|
66 | - return 'name'; |
|
67 | - } elseif ($columnName === 'uid') { |
|
68 | - return 'owner'; |
|
69 | - } else { |
|
70 | - return parent::columnToProperty($columnName); |
|
71 | - } |
|
72 | - } |
|
56 | + /** |
|
57 | + * Transform a database columnname to a property |
|
58 | + * |
|
59 | + * @param string $columnName the name of the column |
|
60 | + * @return string the property name |
|
61 | + * @todo migrate existing database columns to the correct names |
|
62 | + * to be able to drop this direct mapping |
|
63 | + */ |
|
64 | + public function columnToProperty($columnName) { |
|
65 | + if ($columnName === 'category') { |
|
66 | + return 'name'; |
|
67 | + } elseif ($columnName === 'uid') { |
|
68 | + return 'owner'; |
|
69 | + } else { |
|
70 | + return parent::columnToProperty($columnName); |
|
71 | + } |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * Transform a property to a database column name |
|
76 | - * |
|
77 | - * @param string $property the name of the property |
|
78 | - * @return string the column name |
|
79 | - */ |
|
80 | - public function propertyToColumn($property) { |
|
81 | - if ($property === 'name') { |
|
82 | - return 'category'; |
|
83 | - } elseif ($property === 'owner') { |
|
84 | - return 'uid'; |
|
85 | - } else { |
|
86 | - return parent::propertyToColumn($property); |
|
87 | - } |
|
88 | - } |
|
74 | + /** |
|
75 | + * Transform a property to a database column name |
|
76 | + * |
|
77 | + * @param string $property the name of the property |
|
78 | + * @return string the column name |
|
79 | + */ |
|
80 | + public function propertyToColumn($property) { |
|
81 | + if ($property === 'name') { |
|
82 | + return 'category'; |
|
83 | + } elseif ($property === 'owner') { |
|
84 | + return 'uid'; |
|
85 | + } else { |
|
86 | + return parent::propertyToColumn($property); |
|
87 | + } |
|
88 | + } |
|
89 | 89 | } |
@@ -32,7 +32,7 @@ |
||
32 | 32 | * @package OC\AppFramework\Middleware\Security\Exceptions |
33 | 33 | */ |
34 | 34 | class StrictCookieMissingException extends SecurityException { |
35 | - public function __construct() { |
|
36 | - parent::__construct('Strict Cookie has not been found in request.', Http::STATUS_PRECONDITION_FAILED); |
|
37 | - } |
|
35 | + public function __construct() { |
|
36 | + parent::__construct('Strict Cookie has not been found in request.', Http::STATUS_PRECONDITION_FAILED); |
|
37 | + } |
|
38 | 38 | } |
@@ -27,52 +27,52 @@ |
||
27 | 27 | |
28 | 28 | class V1Response extends BaseResponse { |
29 | 29 | |
30 | - /** |
|
31 | - * The V1 endpoint has very limited http status codes basically everything |
|
32 | - * is status 200 except 401 |
|
33 | - * |
|
34 | - * @return int |
|
35 | - */ |
|
36 | - public function getStatus() { |
|
37 | - $status = parent::getStatus(); |
|
38 | - if ($status === Http::STATUS_FORBIDDEN || $status === API::RESPOND_UNAUTHORISED) { |
|
39 | - return Http::STATUS_UNAUTHORIZED; |
|
40 | - } |
|
30 | + /** |
|
31 | + * The V1 endpoint has very limited http status codes basically everything |
|
32 | + * is status 200 except 401 |
|
33 | + * |
|
34 | + * @return int |
|
35 | + */ |
|
36 | + public function getStatus() { |
|
37 | + $status = parent::getStatus(); |
|
38 | + if ($status === Http::STATUS_FORBIDDEN || $status === API::RESPOND_UNAUTHORISED) { |
|
39 | + return Http::STATUS_UNAUTHORIZED; |
|
40 | + } |
|
41 | 41 | |
42 | - return Http::STATUS_OK; |
|
43 | - } |
|
42 | + return Http::STATUS_OK; |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * In v1 all OK is 100 |
|
47 | - * |
|
48 | - * @return int |
|
49 | - */ |
|
50 | - public function getOCSStatus() { |
|
51 | - $status = parent::getOCSStatus(); |
|
45 | + /** |
|
46 | + * In v1 all OK is 100 |
|
47 | + * |
|
48 | + * @return int |
|
49 | + */ |
|
50 | + public function getOCSStatus() { |
|
51 | + $status = parent::getOCSStatus(); |
|
52 | 52 | |
53 | - if ($status === Http::STATUS_OK) { |
|
54 | - return 100; |
|
55 | - } |
|
53 | + if ($status === Http::STATUS_OK) { |
|
54 | + return 100; |
|
55 | + } |
|
56 | 56 | |
57 | - return $status; |
|
58 | - } |
|
57 | + return $status; |
|
58 | + } |
|
59 | 59 | |
60 | - /** |
|
61 | - * Construct the meta part of the response |
|
62 | - * And then late the base class render |
|
63 | - * |
|
64 | - * @return string |
|
65 | - */ |
|
66 | - public function render() { |
|
67 | - $meta = [ |
|
68 | - 'status' => $this->getOCSStatus() === 100 ? 'ok' : 'failure', |
|
69 | - 'statuscode' => $this->getOCSStatus(), |
|
70 | - 'message' => $this->getOCSStatus() === 100 ? 'OK' : $this->statusMessage, |
|
71 | - ]; |
|
60 | + /** |
|
61 | + * Construct the meta part of the response |
|
62 | + * And then late the base class render |
|
63 | + * |
|
64 | + * @return string |
|
65 | + */ |
|
66 | + public function render() { |
|
67 | + $meta = [ |
|
68 | + 'status' => $this->getOCSStatus() === 100 ? 'ok' : 'failure', |
|
69 | + 'statuscode' => $this->getOCSStatus(), |
|
70 | + 'message' => $this->getOCSStatus() === 100 ? 'OK' : $this->statusMessage, |
|
71 | + ]; |
|
72 | 72 | |
73 | - $meta['totalitems'] = $this->itemsCount !== null ? (string)$this->itemsCount : ''; |
|
74 | - $meta['itemsperpage'] = $this->itemsPerPage !== null ? (string)$this->itemsPerPage: ''; |
|
73 | + $meta['totalitems'] = $this->itemsCount !== null ? (string)$this->itemsCount : ''; |
|
74 | + $meta['itemsperpage'] = $this->itemsPerPage !== null ? (string)$this->itemsPerPage: ''; |
|
75 | 75 | |
76 | - return $this->renderResult($meta); |
|
77 | - } |
|
76 | + return $this->renderResult($meta); |
|
77 | + } |
|
78 | 78 | } |
@@ -27,49 +27,49 @@ |
||
27 | 27 | |
28 | 28 | class V2Response extends BaseResponse { |
29 | 29 | |
30 | - /** |
|
31 | - * The V2 endpoint just passes on status codes. |
|
32 | - * Of course we have to map the OCS specific codes to proper HTTP status codes |
|
33 | - * |
|
34 | - * @return int |
|
35 | - */ |
|
36 | - public function getStatus() { |
|
37 | - $status = parent::getStatus(); |
|
38 | - if ($status === API::RESPOND_UNAUTHORISED) { |
|
39 | - return Http::STATUS_UNAUTHORIZED; |
|
40 | - } elseif ($status === API::RESPOND_NOT_FOUND) { |
|
41 | - return Http::STATUS_NOT_FOUND; |
|
42 | - } elseif ($status === API::RESPOND_SERVER_ERROR || $status === API::RESPOND_UNKNOWN_ERROR) { |
|
43 | - return Http::STATUS_INTERNAL_SERVER_ERROR; |
|
44 | - } elseif ($status < 200 || $status > 600) { |
|
45 | - return Http::STATUS_BAD_REQUEST; |
|
46 | - } |
|
30 | + /** |
|
31 | + * The V2 endpoint just passes on status codes. |
|
32 | + * Of course we have to map the OCS specific codes to proper HTTP status codes |
|
33 | + * |
|
34 | + * @return int |
|
35 | + */ |
|
36 | + public function getStatus() { |
|
37 | + $status = parent::getStatus(); |
|
38 | + if ($status === API::RESPOND_UNAUTHORISED) { |
|
39 | + return Http::STATUS_UNAUTHORIZED; |
|
40 | + } elseif ($status === API::RESPOND_NOT_FOUND) { |
|
41 | + return Http::STATUS_NOT_FOUND; |
|
42 | + } elseif ($status === API::RESPOND_SERVER_ERROR || $status === API::RESPOND_UNKNOWN_ERROR) { |
|
43 | + return Http::STATUS_INTERNAL_SERVER_ERROR; |
|
44 | + } elseif ($status < 200 || $status > 600) { |
|
45 | + return Http::STATUS_BAD_REQUEST; |
|
46 | + } |
|
47 | 47 | |
48 | - return $status; |
|
49 | - } |
|
48 | + return $status; |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * Construct the meta part of the response |
|
53 | - * And then late the base class render |
|
54 | - * |
|
55 | - * @return string |
|
56 | - */ |
|
57 | - public function render() { |
|
58 | - $status = parent::getStatus(); |
|
51 | + /** |
|
52 | + * Construct the meta part of the response |
|
53 | + * And then late the base class render |
|
54 | + * |
|
55 | + * @return string |
|
56 | + */ |
|
57 | + public function render() { |
|
58 | + $status = parent::getStatus(); |
|
59 | 59 | |
60 | - $meta = [ |
|
61 | - 'status' => $status >= 200 && $status < 300 ? 'ok' : 'failure', |
|
62 | - 'statuscode' => $this->getOCSStatus(), |
|
63 | - 'message' => $status >= 200 && $status < 300 ? 'OK' : $this->statusMessage, |
|
64 | - ]; |
|
60 | + $meta = [ |
|
61 | + 'status' => $status >= 200 && $status < 300 ? 'ok' : 'failure', |
|
62 | + 'statuscode' => $this->getOCSStatus(), |
|
63 | + 'message' => $status >= 200 && $status < 300 ? 'OK' : $this->statusMessage, |
|
64 | + ]; |
|
65 | 65 | |
66 | - if ($this->itemsCount !== null) { |
|
67 | - $meta['totalitems'] = $this->itemsCount; |
|
68 | - } |
|
69 | - if ($this->itemsPerPage !== null) { |
|
70 | - $meta['itemsperpage'] = $this->itemsPerPage; |
|
71 | - } |
|
66 | + if ($this->itemsCount !== null) { |
|
67 | + $meta['totalitems'] = $this->itemsCount; |
|
68 | + } |
|
69 | + if ($this->itemsPerPage !== null) { |
|
70 | + $meta['itemsperpage'] = $this->itemsPerPage; |
|
71 | + } |
|
72 | 72 | |
73 | - return $this->renderResult($meta); |
|
74 | - } |
|
73 | + return $this->renderResult($meta); |
|
74 | + } |
|
75 | 75 | } |
@@ -43,84 +43,84 @@ |
||
43 | 43 | */ |
44 | 44 | class EntityTypeCollection extends RootCollection { |
45 | 45 | |
46 | - /** @var ILogger */ |
|
47 | - protected $logger; |
|
46 | + /** @var ILogger */ |
|
47 | + protected $logger; |
|
48 | 48 | |
49 | - /** @var IUserManager */ |
|
50 | - protected $userManager; |
|
49 | + /** @var IUserManager */ |
|
50 | + protected $userManager; |
|
51 | 51 | |
52 | - /** @var \Closure */ |
|
53 | - protected $childExistsFunction; |
|
52 | + /** @var \Closure */ |
|
53 | + protected $childExistsFunction; |
|
54 | 54 | |
55 | - /** |
|
56 | - * @param string $name |
|
57 | - * @param ICommentsManager $commentsManager |
|
58 | - * @param IUserManager $userManager |
|
59 | - * @param IUserSession $userSession |
|
60 | - * @param ILogger $logger |
|
61 | - * @param \Closure $childExistsFunction |
|
62 | - */ |
|
63 | - public function __construct( |
|
64 | - $name, |
|
65 | - ICommentsManager $commentsManager, |
|
66 | - IUserManager $userManager, |
|
67 | - IUserSession $userSession, |
|
68 | - ILogger $logger, |
|
69 | - \Closure $childExistsFunction |
|
70 | - ) { |
|
71 | - $name = trim($name); |
|
72 | - if (empty($name) || !is_string($name)) { |
|
73 | - throw new \InvalidArgumentException('"name" parameter must be non-empty string'); |
|
74 | - } |
|
75 | - $this->name = $name; |
|
76 | - $this->commentsManager = $commentsManager; |
|
77 | - $this->logger = $logger; |
|
78 | - $this->userManager = $userManager; |
|
79 | - $this->userSession = $userSession; |
|
80 | - $this->childExistsFunction = $childExistsFunction; |
|
81 | - } |
|
55 | + /** |
|
56 | + * @param string $name |
|
57 | + * @param ICommentsManager $commentsManager |
|
58 | + * @param IUserManager $userManager |
|
59 | + * @param IUserSession $userSession |
|
60 | + * @param ILogger $logger |
|
61 | + * @param \Closure $childExistsFunction |
|
62 | + */ |
|
63 | + public function __construct( |
|
64 | + $name, |
|
65 | + ICommentsManager $commentsManager, |
|
66 | + IUserManager $userManager, |
|
67 | + IUserSession $userSession, |
|
68 | + ILogger $logger, |
|
69 | + \Closure $childExistsFunction |
|
70 | + ) { |
|
71 | + $name = trim($name); |
|
72 | + if (empty($name) || !is_string($name)) { |
|
73 | + throw new \InvalidArgumentException('"name" parameter must be non-empty string'); |
|
74 | + } |
|
75 | + $this->name = $name; |
|
76 | + $this->commentsManager = $commentsManager; |
|
77 | + $this->logger = $logger; |
|
78 | + $this->userManager = $userManager; |
|
79 | + $this->userSession = $userSession; |
|
80 | + $this->childExistsFunction = $childExistsFunction; |
|
81 | + } |
|
82 | 82 | |
83 | - /** |
|
84 | - * Returns a specific child node, referenced by its name |
|
85 | - * |
|
86 | - * This method must throw Sabre\DAV\Exception\NotFound if the node does not |
|
87 | - * exist. |
|
88 | - * |
|
89 | - * @param string $name |
|
90 | - * @return \Sabre\DAV\INode |
|
91 | - * @throws NotFound |
|
92 | - */ |
|
93 | - public function getChild($name) { |
|
94 | - if (!$this->childExists($name)) { |
|
95 | - throw new NotFound('Entity does not exist or is not available'); |
|
96 | - } |
|
97 | - return new EntityCollection( |
|
98 | - $name, |
|
99 | - $this->name, |
|
100 | - $this->commentsManager, |
|
101 | - $this->userManager, |
|
102 | - $this->userSession, |
|
103 | - $this->logger |
|
104 | - ); |
|
105 | - } |
|
83 | + /** |
|
84 | + * Returns a specific child node, referenced by its name |
|
85 | + * |
|
86 | + * This method must throw Sabre\DAV\Exception\NotFound if the node does not |
|
87 | + * exist. |
|
88 | + * |
|
89 | + * @param string $name |
|
90 | + * @return \Sabre\DAV\INode |
|
91 | + * @throws NotFound |
|
92 | + */ |
|
93 | + public function getChild($name) { |
|
94 | + if (!$this->childExists($name)) { |
|
95 | + throw new NotFound('Entity does not exist or is not available'); |
|
96 | + } |
|
97 | + return new EntityCollection( |
|
98 | + $name, |
|
99 | + $this->name, |
|
100 | + $this->commentsManager, |
|
101 | + $this->userManager, |
|
102 | + $this->userSession, |
|
103 | + $this->logger |
|
104 | + ); |
|
105 | + } |
|
106 | 106 | |
107 | - /** |
|
108 | - * Returns an array with all the child nodes |
|
109 | - * |
|
110 | - * @return \Sabre\DAV\INode[] |
|
111 | - * @throws MethodNotAllowed |
|
112 | - */ |
|
113 | - public function getChildren() { |
|
114 | - throw new MethodNotAllowed('No permission to list folder contents'); |
|
115 | - } |
|
107 | + /** |
|
108 | + * Returns an array with all the child nodes |
|
109 | + * |
|
110 | + * @return \Sabre\DAV\INode[] |
|
111 | + * @throws MethodNotAllowed |
|
112 | + */ |
|
113 | + public function getChildren() { |
|
114 | + throw new MethodNotAllowed('No permission to list folder contents'); |
|
115 | + } |
|
116 | 116 | |
117 | - /** |
|
118 | - * Checks if a child-node with the specified name exists |
|
119 | - * |
|
120 | - * @param string $name |
|
121 | - * @return bool |
|
122 | - */ |
|
123 | - public function childExists($name) { |
|
124 | - return call_user_func($this->childExistsFunction, $name); |
|
125 | - } |
|
117 | + /** |
|
118 | + * Checks if a child-node with the specified name exists |
|
119 | + * |
|
120 | + * @param string $name |
|
121 | + * @return bool |
|
122 | + */ |
|
123 | + public function childExists($name) { |
|
124 | + return call_user_func($this->childExistsFunction, $name); |
|
125 | + } |
|
126 | 126 | } |