@@ -37,256 +37,256 @@ |
||
37 | 37 | |
38 | 38 | class CollaborationResourcesController extends OCSController { |
39 | 39 | |
40 | - /** @var IManager */ |
|
41 | - private $manager; |
|
42 | - /** @var IUserSession */ |
|
43 | - private $userSession; |
|
44 | - /** @var ILogger */ |
|
45 | - private $logger; |
|
46 | - |
|
47 | - public function __construct( |
|
48 | - string $appName, |
|
49 | - IRequest $request, |
|
50 | - IManager $manager, |
|
51 | - IUserSession $userSession, |
|
52 | - ILogger $logger |
|
53 | - ) { |
|
54 | - parent::__construct($appName, $request); |
|
55 | - |
|
56 | - $this->manager = $manager; |
|
57 | - $this->userSession = $userSession; |
|
58 | - $this->logger = $logger; |
|
59 | - } |
|
60 | - |
|
61 | - /** |
|
62 | - * @param int $collectionId |
|
63 | - * @return ICollection |
|
64 | - * @throws CollectionException when the collection was not found for the user |
|
65 | - */ |
|
66 | - protected function getCollection(int $collectionId): ICollection { |
|
67 | - $collection = $this->manager->getCollectionForUser($collectionId, $this->userSession->getUser()); |
|
68 | - |
|
69 | - if (!$collection->canAccess($this->userSession->getUser())) { |
|
70 | - throw new CollectionException('Not found'); |
|
71 | - } |
|
72 | - |
|
73 | - return $collection; |
|
74 | - } |
|
75 | - |
|
76 | - /** |
|
77 | - * @NoAdminRequired |
|
78 | - * |
|
79 | - * @param int $collectionId |
|
80 | - * @return DataResponse |
|
81 | - */ |
|
82 | - public function listCollection(int $collectionId): DataResponse { |
|
83 | - try { |
|
84 | - $collection = $this->getCollection($collectionId); |
|
85 | - } catch (CollectionException $e) { |
|
86 | - return new DataResponse([], Http::STATUS_NOT_FOUND); |
|
87 | - } |
|
88 | - |
|
89 | - return $this->respondCollection($collection); |
|
90 | - } |
|
91 | - |
|
92 | - /** |
|
93 | - * @NoAdminRequired |
|
94 | - * |
|
95 | - * @param string $filter |
|
96 | - * @return DataResponse |
|
97 | - */ |
|
98 | - public function searchCollections(string $filter): DataResponse { |
|
99 | - try { |
|
100 | - $collections = $this->manager->searchCollections($this->userSession->getUser(), $filter); |
|
101 | - } catch (CollectionException $e) { |
|
102 | - return new DataResponse([], Http::STATUS_NOT_FOUND); |
|
103 | - } |
|
104 | - |
|
105 | - return new DataResponse($this->prepareCollections($collections)); |
|
106 | - } |
|
107 | - |
|
108 | - /** |
|
109 | - * @NoAdminRequired |
|
110 | - * |
|
111 | - * @param int $collectionId |
|
112 | - * @param string $resourceType |
|
113 | - * @param string $resourceId |
|
114 | - * @return DataResponse |
|
115 | - */ |
|
116 | - public function addResource(int $collectionId, string $resourceType, string $resourceId): DataResponse { |
|
117 | - try { |
|
118 | - $collection = $this->getCollection($collectionId); |
|
119 | - } catch (CollectionException $e) { |
|
120 | - return new DataResponse([], Http::STATUS_NOT_FOUND); |
|
121 | - } |
|
122 | - |
|
123 | - $resource = $this->manager->createResource($resourceType, $resourceId); |
|
124 | - |
|
125 | - if (!$resource->canAccess($this->userSession->getUser())) { |
|
126 | - return new DataResponse([], Http::STATUS_NOT_FOUND); |
|
127 | - } |
|
128 | - |
|
129 | - try { |
|
130 | - $collection->addResource($resource); |
|
131 | - } catch (ResourceException $e) { |
|
132 | - } |
|
133 | - |
|
134 | - return $this->respondCollection($collection); |
|
135 | - } |
|
136 | - |
|
137 | - /** |
|
138 | - * @NoAdminRequired |
|
139 | - * |
|
140 | - * @param int $collectionId |
|
141 | - * @param string $resourceType |
|
142 | - * @param string $resourceId |
|
143 | - * @return DataResponse |
|
144 | - */ |
|
145 | - public function removeResource(int $collectionId, string $resourceType, string $resourceId): DataResponse { |
|
146 | - try { |
|
147 | - $collection = $this->getCollection($collectionId); |
|
148 | - } catch (CollectionException $e) { |
|
149 | - return new DataResponse([], Http::STATUS_NOT_FOUND); |
|
150 | - } |
|
151 | - |
|
152 | - try { |
|
153 | - $resource = $this->manager->getResourceForUser($resourceType, $resourceId, $this->userSession->getUser()); |
|
154 | - } catch (CollectionException $e) { |
|
155 | - return new DataResponse([], Http::STATUS_NOT_FOUND); |
|
156 | - } |
|
157 | - |
|
158 | - $collection->removeResource($resource); |
|
159 | - |
|
160 | - return $this->respondCollection($collection); |
|
161 | - } |
|
162 | - |
|
163 | - /** |
|
164 | - * @NoAdminRequired |
|
165 | - * |
|
166 | - * @param string $resourceType |
|
167 | - * @param string $resourceId |
|
168 | - * @return DataResponse |
|
169 | - */ |
|
170 | - public function getCollectionsByResource(string $resourceType, string $resourceId): DataResponse { |
|
171 | - try { |
|
172 | - $resource = $this->manager->getResourceForUser($resourceType, $resourceId, $this->userSession->getUser()); |
|
173 | - } catch (ResourceException $e) { |
|
174 | - $resource = $this->manager->createResource($resourceType, $resourceId); |
|
175 | - } |
|
176 | - |
|
177 | - if (!$resource->canAccess($this->userSession->getUser())) { |
|
178 | - return new DataResponse([], Http::STATUS_NOT_FOUND); |
|
179 | - } |
|
180 | - |
|
181 | - return new DataResponse($this->prepareCollections($resource->getCollections())); |
|
182 | - } |
|
183 | - |
|
184 | - /** |
|
185 | - * @NoAdminRequired |
|
186 | - * |
|
187 | - * @param string $baseResourceType |
|
188 | - * @param string $baseResourceId |
|
189 | - * @param string $name |
|
190 | - * @return DataResponse |
|
191 | - */ |
|
192 | - public function createCollectionOnResource(string $baseResourceType, string $baseResourceId, string $name): DataResponse { |
|
193 | - if (!isset($name[0]) || isset($name[64])) { |
|
194 | - return new DataResponse([], Http::STATUS_BAD_REQUEST); |
|
195 | - } |
|
196 | - |
|
197 | - try { |
|
198 | - $resource = $this->manager->createResource($baseResourceType, $baseResourceId); |
|
199 | - } catch (CollectionException $e) { |
|
200 | - return new DataResponse([], Http::STATUS_NOT_FOUND); |
|
201 | - } |
|
202 | - |
|
203 | - if (!$resource->canAccess($this->userSession->getUser())) { |
|
204 | - return new DataResponse([], Http::STATUS_NOT_FOUND); |
|
205 | - } |
|
206 | - |
|
207 | - $collection = $this->manager->newCollection($name); |
|
208 | - $collection->addResource($resource); |
|
209 | - |
|
210 | - return $this->respondCollection($collection); |
|
211 | - } |
|
212 | - |
|
213 | - /** |
|
214 | - * @NoAdminRequired |
|
215 | - * |
|
216 | - * @param int $collectionId |
|
217 | - * @param string $collectionName |
|
218 | - * @return DataResponse |
|
219 | - */ |
|
220 | - public function renameCollection(int $collectionId, string $collectionName): DataResponse { |
|
221 | - try { |
|
222 | - $collection = $this->getCollection($collectionId); |
|
223 | - } catch (CollectionException $exception) { |
|
224 | - return new DataResponse([], Http::STATUS_NOT_FOUND); |
|
225 | - } |
|
226 | - |
|
227 | - $collection->setName($collectionName); |
|
228 | - |
|
229 | - return $this->respondCollection($collection); |
|
230 | - } |
|
231 | - |
|
232 | - protected function respondCollection(ICollection $collection): DataResponse { |
|
233 | - try { |
|
234 | - return new DataResponse($this->prepareCollection($collection)); |
|
235 | - } catch (CollectionException $e) { |
|
236 | - return new DataResponse([], Http::STATUS_NOT_FOUND); |
|
237 | - } catch (Exception $e) { |
|
238 | - $this->logger->logException($e); |
|
239 | - return new DataResponse([], Http::STATUS_INTERNAL_SERVER_ERROR); |
|
240 | - } |
|
241 | - } |
|
242 | - |
|
243 | - protected function prepareCollections(array $collections): array { |
|
244 | - $result = []; |
|
245 | - |
|
246 | - foreach ($collections as $collection) { |
|
247 | - try { |
|
248 | - $result[] = $this->prepareCollection($collection); |
|
249 | - } catch (CollectionException $e) { |
|
250 | - } catch (Exception $e) { |
|
251 | - $this->logger->logException($e); |
|
252 | - } |
|
253 | - } |
|
254 | - |
|
255 | - return $result; |
|
256 | - } |
|
257 | - |
|
258 | - protected function prepareCollection(ICollection $collection): array { |
|
259 | - if (!$collection->canAccess($this->userSession->getUser())) { |
|
260 | - throw new CollectionException('Can not access collection'); |
|
261 | - } |
|
262 | - |
|
263 | - return [ |
|
264 | - 'id' => $collection->getId(), |
|
265 | - 'name' => $collection->getName(), |
|
266 | - 'resources' => $this->prepareResources($collection->getResources()), |
|
267 | - ]; |
|
268 | - } |
|
269 | - |
|
270 | - protected function prepareResources(array $resources): ?array { |
|
271 | - $result = []; |
|
272 | - |
|
273 | - foreach ($resources as $resource) { |
|
274 | - try { |
|
275 | - $result[] = $this->prepareResource($resource); |
|
276 | - } catch (ResourceException $e) { |
|
277 | - } catch (Exception $e) { |
|
278 | - $this->logger->logException($e); |
|
279 | - } |
|
280 | - } |
|
281 | - |
|
282 | - return $result; |
|
283 | - } |
|
284 | - |
|
285 | - protected function prepareResource(IResource $resource): array { |
|
286 | - if (!$resource->canAccess($this->userSession->getUser())) { |
|
287 | - throw new ResourceException('Can not access resource'); |
|
288 | - } |
|
289 | - |
|
290 | - return $resource->getRichObject(); |
|
291 | - } |
|
40 | + /** @var IManager */ |
|
41 | + private $manager; |
|
42 | + /** @var IUserSession */ |
|
43 | + private $userSession; |
|
44 | + /** @var ILogger */ |
|
45 | + private $logger; |
|
46 | + |
|
47 | + public function __construct( |
|
48 | + string $appName, |
|
49 | + IRequest $request, |
|
50 | + IManager $manager, |
|
51 | + IUserSession $userSession, |
|
52 | + ILogger $logger |
|
53 | + ) { |
|
54 | + parent::__construct($appName, $request); |
|
55 | + |
|
56 | + $this->manager = $manager; |
|
57 | + $this->userSession = $userSession; |
|
58 | + $this->logger = $logger; |
|
59 | + } |
|
60 | + |
|
61 | + /** |
|
62 | + * @param int $collectionId |
|
63 | + * @return ICollection |
|
64 | + * @throws CollectionException when the collection was not found for the user |
|
65 | + */ |
|
66 | + protected function getCollection(int $collectionId): ICollection { |
|
67 | + $collection = $this->manager->getCollectionForUser($collectionId, $this->userSession->getUser()); |
|
68 | + |
|
69 | + if (!$collection->canAccess($this->userSession->getUser())) { |
|
70 | + throw new CollectionException('Not found'); |
|
71 | + } |
|
72 | + |
|
73 | + return $collection; |
|
74 | + } |
|
75 | + |
|
76 | + /** |
|
77 | + * @NoAdminRequired |
|
78 | + * |
|
79 | + * @param int $collectionId |
|
80 | + * @return DataResponse |
|
81 | + */ |
|
82 | + public function listCollection(int $collectionId): DataResponse { |
|
83 | + try { |
|
84 | + $collection = $this->getCollection($collectionId); |
|
85 | + } catch (CollectionException $e) { |
|
86 | + return new DataResponse([], Http::STATUS_NOT_FOUND); |
|
87 | + } |
|
88 | + |
|
89 | + return $this->respondCollection($collection); |
|
90 | + } |
|
91 | + |
|
92 | + /** |
|
93 | + * @NoAdminRequired |
|
94 | + * |
|
95 | + * @param string $filter |
|
96 | + * @return DataResponse |
|
97 | + */ |
|
98 | + public function searchCollections(string $filter): DataResponse { |
|
99 | + try { |
|
100 | + $collections = $this->manager->searchCollections($this->userSession->getUser(), $filter); |
|
101 | + } catch (CollectionException $e) { |
|
102 | + return new DataResponse([], Http::STATUS_NOT_FOUND); |
|
103 | + } |
|
104 | + |
|
105 | + return new DataResponse($this->prepareCollections($collections)); |
|
106 | + } |
|
107 | + |
|
108 | + /** |
|
109 | + * @NoAdminRequired |
|
110 | + * |
|
111 | + * @param int $collectionId |
|
112 | + * @param string $resourceType |
|
113 | + * @param string $resourceId |
|
114 | + * @return DataResponse |
|
115 | + */ |
|
116 | + public function addResource(int $collectionId, string $resourceType, string $resourceId): DataResponse { |
|
117 | + try { |
|
118 | + $collection = $this->getCollection($collectionId); |
|
119 | + } catch (CollectionException $e) { |
|
120 | + return new DataResponse([], Http::STATUS_NOT_FOUND); |
|
121 | + } |
|
122 | + |
|
123 | + $resource = $this->manager->createResource($resourceType, $resourceId); |
|
124 | + |
|
125 | + if (!$resource->canAccess($this->userSession->getUser())) { |
|
126 | + return new DataResponse([], Http::STATUS_NOT_FOUND); |
|
127 | + } |
|
128 | + |
|
129 | + try { |
|
130 | + $collection->addResource($resource); |
|
131 | + } catch (ResourceException $e) { |
|
132 | + } |
|
133 | + |
|
134 | + return $this->respondCollection($collection); |
|
135 | + } |
|
136 | + |
|
137 | + /** |
|
138 | + * @NoAdminRequired |
|
139 | + * |
|
140 | + * @param int $collectionId |
|
141 | + * @param string $resourceType |
|
142 | + * @param string $resourceId |
|
143 | + * @return DataResponse |
|
144 | + */ |
|
145 | + public function removeResource(int $collectionId, string $resourceType, string $resourceId): DataResponse { |
|
146 | + try { |
|
147 | + $collection = $this->getCollection($collectionId); |
|
148 | + } catch (CollectionException $e) { |
|
149 | + return new DataResponse([], Http::STATUS_NOT_FOUND); |
|
150 | + } |
|
151 | + |
|
152 | + try { |
|
153 | + $resource = $this->manager->getResourceForUser($resourceType, $resourceId, $this->userSession->getUser()); |
|
154 | + } catch (CollectionException $e) { |
|
155 | + return new DataResponse([], Http::STATUS_NOT_FOUND); |
|
156 | + } |
|
157 | + |
|
158 | + $collection->removeResource($resource); |
|
159 | + |
|
160 | + return $this->respondCollection($collection); |
|
161 | + } |
|
162 | + |
|
163 | + /** |
|
164 | + * @NoAdminRequired |
|
165 | + * |
|
166 | + * @param string $resourceType |
|
167 | + * @param string $resourceId |
|
168 | + * @return DataResponse |
|
169 | + */ |
|
170 | + public function getCollectionsByResource(string $resourceType, string $resourceId): DataResponse { |
|
171 | + try { |
|
172 | + $resource = $this->manager->getResourceForUser($resourceType, $resourceId, $this->userSession->getUser()); |
|
173 | + } catch (ResourceException $e) { |
|
174 | + $resource = $this->manager->createResource($resourceType, $resourceId); |
|
175 | + } |
|
176 | + |
|
177 | + if (!$resource->canAccess($this->userSession->getUser())) { |
|
178 | + return new DataResponse([], Http::STATUS_NOT_FOUND); |
|
179 | + } |
|
180 | + |
|
181 | + return new DataResponse($this->prepareCollections($resource->getCollections())); |
|
182 | + } |
|
183 | + |
|
184 | + /** |
|
185 | + * @NoAdminRequired |
|
186 | + * |
|
187 | + * @param string $baseResourceType |
|
188 | + * @param string $baseResourceId |
|
189 | + * @param string $name |
|
190 | + * @return DataResponse |
|
191 | + */ |
|
192 | + public function createCollectionOnResource(string $baseResourceType, string $baseResourceId, string $name): DataResponse { |
|
193 | + if (!isset($name[0]) || isset($name[64])) { |
|
194 | + return new DataResponse([], Http::STATUS_BAD_REQUEST); |
|
195 | + } |
|
196 | + |
|
197 | + try { |
|
198 | + $resource = $this->manager->createResource($baseResourceType, $baseResourceId); |
|
199 | + } catch (CollectionException $e) { |
|
200 | + return new DataResponse([], Http::STATUS_NOT_FOUND); |
|
201 | + } |
|
202 | + |
|
203 | + if (!$resource->canAccess($this->userSession->getUser())) { |
|
204 | + return new DataResponse([], Http::STATUS_NOT_FOUND); |
|
205 | + } |
|
206 | + |
|
207 | + $collection = $this->manager->newCollection($name); |
|
208 | + $collection->addResource($resource); |
|
209 | + |
|
210 | + return $this->respondCollection($collection); |
|
211 | + } |
|
212 | + |
|
213 | + /** |
|
214 | + * @NoAdminRequired |
|
215 | + * |
|
216 | + * @param int $collectionId |
|
217 | + * @param string $collectionName |
|
218 | + * @return DataResponse |
|
219 | + */ |
|
220 | + public function renameCollection(int $collectionId, string $collectionName): DataResponse { |
|
221 | + try { |
|
222 | + $collection = $this->getCollection($collectionId); |
|
223 | + } catch (CollectionException $exception) { |
|
224 | + return new DataResponse([], Http::STATUS_NOT_FOUND); |
|
225 | + } |
|
226 | + |
|
227 | + $collection->setName($collectionName); |
|
228 | + |
|
229 | + return $this->respondCollection($collection); |
|
230 | + } |
|
231 | + |
|
232 | + protected function respondCollection(ICollection $collection): DataResponse { |
|
233 | + try { |
|
234 | + return new DataResponse($this->prepareCollection($collection)); |
|
235 | + } catch (CollectionException $e) { |
|
236 | + return new DataResponse([], Http::STATUS_NOT_FOUND); |
|
237 | + } catch (Exception $e) { |
|
238 | + $this->logger->logException($e); |
|
239 | + return new DataResponse([], Http::STATUS_INTERNAL_SERVER_ERROR); |
|
240 | + } |
|
241 | + } |
|
242 | + |
|
243 | + protected function prepareCollections(array $collections): array { |
|
244 | + $result = []; |
|
245 | + |
|
246 | + foreach ($collections as $collection) { |
|
247 | + try { |
|
248 | + $result[] = $this->prepareCollection($collection); |
|
249 | + } catch (CollectionException $e) { |
|
250 | + } catch (Exception $e) { |
|
251 | + $this->logger->logException($e); |
|
252 | + } |
|
253 | + } |
|
254 | + |
|
255 | + return $result; |
|
256 | + } |
|
257 | + |
|
258 | + protected function prepareCollection(ICollection $collection): array { |
|
259 | + if (!$collection->canAccess($this->userSession->getUser())) { |
|
260 | + throw new CollectionException('Can not access collection'); |
|
261 | + } |
|
262 | + |
|
263 | + return [ |
|
264 | + 'id' => $collection->getId(), |
|
265 | + 'name' => $collection->getName(), |
|
266 | + 'resources' => $this->prepareResources($collection->getResources()), |
|
267 | + ]; |
|
268 | + } |
|
269 | + |
|
270 | + protected function prepareResources(array $resources): ?array { |
|
271 | + $result = []; |
|
272 | + |
|
273 | + foreach ($resources as $resource) { |
|
274 | + try { |
|
275 | + $result[] = $this->prepareResource($resource); |
|
276 | + } catch (ResourceException $e) { |
|
277 | + } catch (Exception $e) { |
|
278 | + $this->logger->logException($e); |
|
279 | + } |
|
280 | + } |
|
281 | + |
|
282 | + return $result; |
|
283 | + } |
|
284 | + |
|
285 | + protected function prepareResource(IResource $resource): array { |
|
286 | + if (!$resource->canAccess($this->userSession->getUser())) { |
|
287 | + throw new ResourceException('Can not access resource'); |
|
288 | + } |
|
289 | + |
|
290 | + return $resource->getRichObject(); |
|
291 | + } |
|
292 | 292 | } |
@@ -33,89 +33,89 @@ |
||
33 | 33 | */ |
34 | 34 | interface ISimpleFile { |
35 | 35 | |
36 | - /** |
|
37 | - * Get the name |
|
38 | - * |
|
39 | - * @return string |
|
40 | - * @since 11.0.0 |
|
41 | - */ |
|
42 | - public function getName(); |
|
36 | + /** |
|
37 | + * Get the name |
|
38 | + * |
|
39 | + * @return string |
|
40 | + * @since 11.0.0 |
|
41 | + */ |
|
42 | + public function getName(); |
|
43 | 43 | |
44 | - /** |
|
45 | - * Get the size in bytes |
|
46 | - * |
|
47 | - * @return int |
|
48 | - * @since 11.0.0 |
|
49 | - */ |
|
50 | - public function getSize(); |
|
44 | + /** |
|
45 | + * Get the size in bytes |
|
46 | + * |
|
47 | + * @return int |
|
48 | + * @since 11.0.0 |
|
49 | + */ |
|
50 | + public function getSize(); |
|
51 | 51 | |
52 | - /** |
|
53 | - * Get the ETag |
|
54 | - * |
|
55 | - * @return string |
|
56 | - * @since 11.0.0 |
|
57 | - */ |
|
58 | - public function getETag(); |
|
52 | + /** |
|
53 | + * Get the ETag |
|
54 | + * |
|
55 | + * @return string |
|
56 | + * @since 11.0.0 |
|
57 | + */ |
|
58 | + public function getETag(); |
|
59 | 59 | |
60 | - /** |
|
61 | - * Get the last modification time |
|
62 | - * |
|
63 | - * @return int |
|
64 | - * @since 11.0.0 |
|
65 | - */ |
|
66 | - public function getMTime(); |
|
60 | + /** |
|
61 | + * Get the last modification time |
|
62 | + * |
|
63 | + * @return int |
|
64 | + * @since 11.0.0 |
|
65 | + */ |
|
66 | + public function getMTime(); |
|
67 | 67 | |
68 | - /** |
|
69 | - * Get the content |
|
70 | - * |
|
71 | - * @throws NotPermittedException |
|
72 | - * @throws NotFoundException |
|
73 | - * @return string |
|
74 | - * @since 11.0.0 |
|
75 | - */ |
|
76 | - public function getContent(); |
|
68 | + /** |
|
69 | + * Get the content |
|
70 | + * |
|
71 | + * @throws NotPermittedException |
|
72 | + * @throws NotFoundException |
|
73 | + * @return string |
|
74 | + * @since 11.0.0 |
|
75 | + */ |
|
76 | + public function getContent(); |
|
77 | 77 | |
78 | - /** |
|
79 | - * Overwrite the file |
|
80 | - * |
|
81 | - * @param string|resource $data |
|
82 | - * @throws NotPermittedException |
|
83 | - * @throws NotFoundException |
|
84 | - * @since 11.0.0 |
|
85 | - */ |
|
86 | - public function putContent($data); |
|
78 | + /** |
|
79 | + * Overwrite the file |
|
80 | + * |
|
81 | + * @param string|resource $data |
|
82 | + * @throws NotPermittedException |
|
83 | + * @throws NotFoundException |
|
84 | + * @since 11.0.0 |
|
85 | + */ |
|
86 | + public function putContent($data); |
|
87 | 87 | |
88 | - /** |
|
89 | - * Delete the file |
|
90 | - * |
|
91 | - * @throws NotPermittedException |
|
92 | - * @since 11.0.0 |
|
93 | - */ |
|
94 | - public function delete(); |
|
88 | + /** |
|
89 | + * Delete the file |
|
90 | + * |
|
91 | + * @throws NotPermittedException |
|
92 | + * @since 11.0.0 |
|
93 | + */ |
|
94 | + public function delete(); |
|
95 | 95 | |
96 | - /** |
|
97 | - * Get the MimeType |
|
98 | - * |
|
99 | - * @return string |
|
100 | - * @since 11.0.0 |
|
101 | - */ |
|
102 | - public function getMimeType(); |
|
96 | + /** |
|
97 | + * Get the MimeType |
|
98 | + * |
|
99 | + * @return string |
|
100 | + * @since 11.0.0 |
|
101 | + */ |
|
102 | + public function getMimeType(); |
|
103 | 103 | |
104 | - /** |
|
105 | - * Open the file as stream for reading, resulting resource can be operated as stream like the result from php's own fopen |
|
106 | - * |
|
107 | - * @return resource |
|
108 | - * @throws \OCP\Files\NotPermittedException |
|
109 | - * @since 14.0.0 |
|
110 | - */ |
|
111 | - public function read(); |
|
104 | + /** |
|
105 | + * Open the file as stream for reading, resulting resource can be operated as stream like the result from php's own fopen |
|
106 | + * |
|
107 | + * @return resource |
|
108 | + * @throws \OCP\Files\NotPermittedException |
|
109 | + * @since 14.0.0 |
|
110 | + */ |
|
111 | + public function read(); |
|
112 | 112 | |
113 | - /** |
|
114 | - * Open the file as stream for writing, resulting resource can be operated as stream like the result from php's own fopen |
|
115 | - * |
|
116 | - * @return resource |
|
117 | - * @throws \OCP\Files\NotPermittedException |
|
118 | - * @since 14.0.0 |
|
119 | - */ |
|
120 | - public function write(); |
|
113 | + /** |
|
114 | + * Open the file as stream for writing, resulting resource can be operated as stream like the result from php's own fopen |
|
115 | + * |
|
116 | + * @return resource |
|
117 | + * @throws \OCP\Files\NotPermittedException |
|
118 | + * @since 14.0.0 |
|
119 | + */ |
|
120 | + public function write(); |
|
121 | 121 | } |
@@ -51,145 +51,145 @@ |
||
51 | 51 | interface IFullTextSearchManager { |
52 | 52 | |
53 | 53 | |
54 | - /** |
|
55 | - * Register a IProviderService. |
|
56 | - * |
|
57 | - * @since 15.0.0 |
|
58 | - * |
|
59 | - * @param IProviderService $providerService |
|
60 | - */ |
|
61 | - public function registerProviderService(IProviderService $providerService); |
|
62 | - |
|
63 | - /** |
|
64 | - * Register a IIndexService. |
|
65 | - * |
|
66 | - * @since 15.0.0 |
|
67 | - * |
|
68 | - * @param IIndexService $indexService |
|
69 | - */ |
|
70 | - public function registerIndexService(IIndexService $indexService); |
|
71 | - |
|
72 | - /** |
|
73 | - * Register a ISearchService. |
|
74 | - * |
|
75 | - * @since 15.0.0 |
|
76 | - * |
|
77 | - * @param ISearchService $searchService |
|
78 | - */ |
|
79 | - public function registerSearchService(ISearchService $searchService); |
|
80 | - |
|
81 | - /** |
|
82 | - * returns true is Full Text Search is available (app is present and Service |
|
83 | - * are registered) |
|
84 | - * |
|
85 | - * @since 16.0.0 |
|
86 | - * |
|
87 | - * @return bool |
|
88 | - */ |
|
89 | - public function isAvailable(): bool; |
|
90 | - |
|
91 | - |
|
92 | - /** |
|
93 | - * Add the Javascript API in the navigation page of an app. |
|
94 | - * Needed to replace the default search. |
|
95 | - * |
|
96 | - * @since 15.0.0 |
|
97 | - */ |
|
98 | - public function addJavascriptAPI(); |
|
99 | - |
|
100 | - |
|
101 | - /** |
|
102 | - * Check if the provider $providerId is already indexed. |
|
103 | - * |
|
104 | - * @since 15.0.0 |
|
105 | - * |
|
106 | - * @param string $providerId |
|
107 | - * |
|
108 | - * @return bool |
|
109 | - */ |
|
110 | - public function isProviderIndexed(string $providerId): bool; |
|
111 | - |
|
112 | - |
|
113 | - /** |
|
114 | - * Retrieve an Index from the database, based on the Id of the Provider |
|
115 | - * and the Id of the Document |
|
116 | - * |
|
117 | - * @since 15.0.0 |
|
118 | - * |
|
119 | - * @param string $providerId |
|
120 | - * @param string $documentId |
|
121 | - * |
|
122 | - * @return IIndex |
|
123 | - */ |
|
124 | - public function getIndex(string $providerId, string $documentId): IIndex; |
|
125 | - |
|
126 | - |
|
127 | - /** |
|
128 | - * Create a new Index. |
|
129 | - * |
|
130 | - * This method must be called when a new document is created. |
|
131 | - * |
|
132 | - * @since 15.0.0 |
|
133 | - * |
|
134 | - * @param string $providerId |
|
135 | - * @param string $documentId |
|
136 | - * @param string $userId |
|
137 | - * @param int $status |
|
138 | - * |
|
139 | - * @return IIndex |
|
140 | - */ |
|
141 | - public function createIndex(string $providerId, string $documentId, string $userId, int $status = 0): IIndex; |
|
142 | - |
|
143 | - |
|
144 | - /** |
|
145 | - * Update the status of an Index. status is a bitflag, setting $reset to |
|
146 | - * true will reset the status to the value defined in the parameter. |
|
147 | - * |
|
148 | - * @since 15.0.0 |
|
149 | - * |
|
150 | - * @param string $providerId |
|
151 | - * @param string $documentId |
|
152 | - * @param int $status |
|
153 | - * @param bool $reset |
|
154 | - */ |
|
155 | - public function updateIndexStatus(string $providerId, string $documentId, int $status, bool $reset = false); |
|
156 | - |
|
157 | - |
|
158 | - /** |
|
159 | - * Update the status of an array of Index. status is a bit flag, setting $reset to |
|
160 | - * true will reset the status to the value defined in the parameter. |
|
161 | - * |
|
162 | - * @since 15.0.0 |
|
163 | - * |
|
164 | - * @param string $providerId |
|
165 | - * @param array $documentIds |
|
166 | - * @param int $status |
|
167 | - * @param bool $reset |
|
168 | - */ |
|
169 | - public function updateIndexesStatus(string $providerId, array $documentIds, int $status, bool $reset = false); |
|
170 | - |
|
171 | - /** |
|
172 | - * Update an array of Index. |
|
173 | - * |
|
174 | - * @since 15.0.0 |
|
175 | - * |
|
176 | - * @param IIndex[] $indexes |
|
177 | - */ |
|
178 | - public function updateIndexes(array $indexes); |
|
179 | - |
|
180 | - /** |
|
181 | - * Search using an array as request. If $userId is empty, will use the |
|
182 | - * current session. |
|
183 | - * |
|
184 | - * @see ISearchService::generateSearchRequest |
|
185 | - * |
|
186 | - * @since 15.0.0 |
|
187 | - * |
|
188 | - * @param array $request |
|
189 | - * @param string $userId |
|
190 | - * @return ISearchResult[] |
|
191 | - */ |
|
192 | - public function search(array $request, string $userId = ''): array; |
|
54 | + /** |
|
55 | + * Register a IProviderService. |
|
56 | + * |
|
57 | + * @since 15.0.0 |
|
58 | + * |
|
59 | + * @param IProviderService $providerService |
|
60 | + */ |
|
61 | + public function registerProviderService(IProviderService $providerService); |
|
62 | + |
|
63 | + /** |
|
64 | + * Register a IIndexService. |
|
65 | + * |
|
66 | + * @since 15.0.0 |
|
67 | + * |
|
68 | + * @param IIndexService $indexService |
|
69 | + */ |
|
70 | + public function registerIndexService(IIndexService $indexService); |
|
71 | + |
|
72 | + /** |
|
73 | + * Register a ISearchService. |
|
74 | + * |
|
75 | + * @since 15.0.0 |
|
76 | + * |
|
77 | + * @param ISearchService $searchService |
|
78 | + */ |
|
79 | + public function registerSearchService(ISearchService $searchService); |
|
80 | + |
|
81 | + /** |
|
82 | + * returns true is Full Text Search is available (app is present and Service |
|
83 | + * are registered) |
|
84 | + * |
|
85 | + * @since 16.0.0 |
|
86 | + * |
|
87 | + * @return bool |
|
88 | + */ |
|
89 | + public function isAvailable(): bool; |
|
90 | + |
|
91 | + |
|
92 | + /** |
|
93 | + * Add the Javascript API in the navigation page of an app. |
|
94 | + * Needed to replace the default search. |
|
95 | + * |
|
96 | + * @since 15.0.0 |
|
97 | + */ |
|
98 | + public function addJavascriptAPI(); |
|
99 | + |
|
100 | + |
|
101 | + /** |
|
102 | + * Check if the provider $providerId is already indexed. |
|
103 | + * |
|
104 | + * @since 15.0.0 |
|
105 | + * |
|
106 | + * @param string $providerId |
|
107 | + * |
|
108 | + * @return bool |
|
109 | + */ |
|
110 | + public function isProviderIndexed(string $providerId): bool; |
|
111 | + |
|
112 | + |
|
113 | + /** |
|
114 | + * Retrieve an Index from the database, based on the Id of the Provider |
|
115 | + * and the Id of the Document |
|
116 | + * |
|
117 | + * @since 15.0.0 |
|
118 | + * |
|
119 | + * @param string $providerId |
|
120 | + * @param string $documentId |
|
121 | + * |
|
122 | + * @return IIndex |
|
123 | + */ |
|
124 | + public function getIndex(string $providerId, string $documentId): IIndex; |
|
125 | + |
|
126 | + |
|
127 | + /** |
|
128 | + * Create a new Index. |
|
129 | + * |
|
130 | + * This method must be called when a new document is created. |
|
131 | + * |
|
132 | + * @since 15.0.0 |
|
133 | + * |
|
134 | + * @param string $providerId |
|
135 | + * @param string $documentId |
|
136 | + * @param string $userId |
|
137 | + * @param int $status |
|
138 | + * |
|
139 | + * @return IIndex |
|
140 | + */ |
|
141 | + public function createIndex(string $providerId, string $documentId, string $userId, int $status = 0): IIndex; |
|
142 | + |
|
143 | + |
|
144 | + /** |
|
145 | + * Update the status of an Index. status is a bitflag, setting $reset to |
|
146 | + * true will reset the status to the value defined in the parameter. |
|
147 | + * |
|
148 | + * @since 15.0.0 |
|
149 | + * |
|
150 | + * @param string $providerId |
|
151 | + * @param string $documentId |
|
152 | + * @param int $status |
|
153 | + * @param bool $reset |
|
154 | + */ |
|
155 | + public function updateIndexStatus(string $providerId, string $documentId, int $status, bool $reset = false); |
|
156 | + |
|
157 | + |
|
158 | + /** |
|
159 | + * Update the status of an array of Index. status is a bit flag, setting $reset to |
|
160 | + * true will reset the status to the value defined in the parameter. |
|
161 | + * |
|
162 | + * @since 15.0.0 |
|
163 | + * |
|
164 | + * @param string $providerId |
|
165 | + * @param array $documentIds |
|
166 | + * @param int $status |
|
167 | + * @param bool $reset |
|
168 | + */ |
|
169 | + public function updateIndexesStatus(string $providerId, array $documentIds, int $status, bool $reset = false); |
|
170 | + |
|
171 | + /** |
|
172 | + * Update an array of Index. |
|
173 | + * |
|
174 | + * @since 15.0.0 |
|
175 | + * |
|
176 | + * @param IIndex[] $indexes |
|
177 | + */ |
|
178 | + public function updateIndexes(array $indexes); |
|
179 | + |
|
180 | + /** |
|
181 | + * Search using an array as request. If $userId is empty, will use the |
|
182 | + * current session. |
|
183 | + * |
|
184 | + * @see ISearchService::generateSearchRequest |
|
185 | + * |
|
186 | + * @since 15.0.0 |
|
187 | + * |
|
188 | + * @param array $request |
|
189 | + * @param string $userId |
|
190 | + * @return ISearchResult[] |
|
191 | + */ |
|
192 | + public function search(array $request, string $userId = ''): array; |
|
193 | 193 | |
194 | 194 | |
195 | 195 | } |
@@ -48,194 +48,194 @@ |
||
48 | 48 | class FullTextSearchManager implements IFullTextSearchManager { |
49 | 49 | |
50 | 50 | |
51 | - /** @var IProviderService */ |
|
52 | - private $providerService; |
|
53 | - |
|
54 | - /** @var IIndexService */ |
|
55 | - private $indexService; |
|
56 | - |
|
57 | - /** @var ISearchService */ |
|
58 | - private $searchService; |
|
59 | - |
|
60 | - |
|
61 | - /** |
|
62 | - * @since 15.0.0 |
|
63 | - * |
|
64 | - * @param IProviderService $providerService |
|
65 | - */ |
|
66 | - public function registerProviderService(IProviderService $providerService) { |
|
67 | - $this->providerService = $providerService; |
|
68 | - } |
|
69 | - |
|
70 | - /** |
|
71 | - * @since 15.0.0 |
|
72 | - * |
|
73 | - * @param IIndexService $indexService |
|
74 | - */ |
|
75 | - public function registerIndexService(IIndexService $indexService) { |
|
76 | - $this->indexService = $indexService; |
|
77 | - } |
|
78 | - |
|
79 | - /** |
|
80 | - * @since 15.0.0 |
|
81 | - * |
|
82 | - * @param ISearchService $searchService |
|
83 | - */ |
|
84 | - public function registerSearchService(ISearchService $searchService) { |
|
85 | - $this->searchService = $searchService; |
|
86 | - } |
|
87 | - |
|
88 | - /** |
|
89 | - * @since 16.0.0 |
|
90 | - * |
|
91 | - * @return bool |
|
92 | - */ |
|
93 | - public function isAvailable(): bool { |
|
94 | - if ($this->indexService === null || |
|
95 | - $this->providerService === null || |
|
96 | - $this->searchService === null) { |
|
97 | - return false; |
|
98 | - } |
|
99 | - |
|
100 | - return true; |
|
101 | - } |
|
102 | - |
|
103 | - |
|
104 | - /** |
|
105 | - * @return IProviderService |
|
106 | - * @throws FullTextSearchAppNotAvailableException |
|
107 | - */ |
|
108 | - private function getProviderService(): IProviderService { |
|
109 | - if ($this->providerService === null) { |
|
110 | - throw new FullTextSearchAppNotAvailableException('No IProviderService registered'); |
|
111 | - } |
|
112 | - |
|
113 | - return $this->providerService; |
|
114 | - } |
|
115 | - |
|
116 | - |
|
117 | - /** |
|
118 | - * @return IIndexService |
|
119 | - * @throws FullTextSearchAppNotAvailableException |
|
120 | - */ |
|
121 | - private function getIndexService(): IIndexService { |
|
122 | - if ($this->indexService === null) { |
|
123 | - throw new FullTextSearchAppNotAvailableException('No IIndexService registered'); |
|
124 | - } |
|
125 | - |
|
126 | - return $this->indexService; |
|
127 | - } |
|
128 | - |
|
129 | - |
|
130 | - /** |
|
131 | - * @return ISearchService |
|
132 | - * @throws FullTextSearchAppNotAvailableException |
|
133 | - */ |
|
134 | - private function getSearchService(): ISearchService { |
|
135 | - if ($this->searchService === null) { |
|
136 | - throw new FullTextSearchAppNotAvailableException('No ISearchService registered'); |
|
137 | - } |
|
138 | - |
|
139 | - return $this->searchService; |
|
140 | - } |
|
141 | - |
|
142 | - |
|
143 | - /** |
|
144 | - * @throws FullTextSearchAppNotAvailableException |
|
145 | - */ |
|
146 | - public function addJavascriptAPI() { |
|
147 | - $this->getProviderService()->addJavascriptAPI(); |
|
148 | - } |
|
149 | - |
|
150 | - |
|
151 | - /** |
|
152 | - * @param string $providerId |
|
153 | - * |
|
154 | - * @return bool |
|
155 | - * @throws FullTextSearchAppNotAvailableException |
|
156 | - */ |
|
157 | - public function isProviderIndexed(string $providerId): bool { |
|
158 | - return $this->getProviderService()->isProviderIndexed($providerId); |
|
159 | - } |
|
160 | - |
|
161 | - |
|
162 | - /** |
|
163 | - * @param string $providerId |
|
164 | - * @param string $documentId |
|
165 | - * @return IIndex |
|
166 | - * @throws FullTextSearchAppNotAvailableException |
|
167 | - */ |
|
168 | - public function getIndex(string $providerId, string $documentId): IIndex { |
|
169 | - return $this->getIndexService()->getIndex($providerId, $documentId); |
|
170 | - } |
|
171 | - |
|
172 | - /** |
|
173 | - * @param string $providerId |
|
174 | - * @param string $documentId |
|
175 | - * @param string $userId |
|
176 | - * @param int $status |
|
177 | - * |
|
178 | - * @see IIndex for available value for $status. |
|
179 | - * |
|
180 | - * @return IIndex |
|
181 | - * @throws FullTextSearchAppNotAvailableException |
|
182 | - */ |
|
183 | - public function createIndex(string $providerId, string $documentId, string $userId, int $status = 0): IIndex { |
|
184 | - return $this->getIndexService()->createIndex($providerId, $documentId, $userId, $status); |
|
185 | - } |
|
186 | - |
|
187 | - |
|
188 | - /** |
|
189 | - * @param string $providerId |
|
190 | - * @param string $documentId |
|
191 | - * @param int $status |
|
192 | - * @param bool $reset |
|
193 | - * |
|
194 | - * @see IIndex for available value for $status. |
|
195 | - * |
|
196 | - * @throws FullTextSearchAppNotAvailableException |
|
197 | - */ |
|
198 | - public function updateIndexStatus(string $providerId, string $documentId, int $status, bool $reset = false) { |
|
199 | - $this->getIndexService()->updateIndexStatus($providerId, $documentId, $status, $reset); |
|
200 | - } |
|
201 | - |
|
202 | - /** |
|
203 | - * @param string $providerId |
|
204 | - * @param array $documentIds |
|
205 | - * @param int $status |
|
206 | - * @param bool $reset |
|
207 | - * |
|
208 | - * @see IIndex for available value for $status. |
|
209 | - * |
|
210 | - * @throws FullTextSearchAppNotAvailableException |
|
211 | - */ |
|
212 | - public function updateIndexesStatus(string $providerId, array $documentIds, int $status, bool $reset = false) { |
|
213 | - $this->getIndexService()->updateIndexesStatus($providerId, $documentIds, $status, $reset); |
|
214 | - } |
|
215 | - |
|
216 | - |
|
217 | - /** |
|
218 | - * @param IIndex[] $indexes |
|
219 | - * |
|
220 | - * @throws FullTextSearchAppNotAvailableException |
|
221 | - */ |
|
222 | - public function updateIndexes(array $indexes) { |
|
223 | - $this->getIndexService()->updateIndexes($indexes); |
|
224 | - } |
|
225 | - |
|
226 | - |
|
227 | - /** |
|
228 | - * @param array $request |
|
229 | - * @param string $userId |
|
230 | - * |
|
231 | - * @return ISearchResult[] |
|
232 | - * @throws FullTextSearchAppNotAvailableException |
|
233 | - */ |
|
234 | - public function search(array $request, string $userId = ''): array { |
|
235 | - $searchRequest = $this->getSearchService()->generateSearchRequest($request); |
|
236 | - |
|
237 | - return $this->getSearchService()->search($userId, $searchRequest); |
|
238 | - } |
|
51 | + /** @var IProviderService */ |
|
52 | + private $providerService; |
|
53 | + |
|
54 | + /** @var IIndexService */ |
|
55 | + private $indexService; |
|
56 | + |
|
57 | + /** @var ISearchService */ |
|
58 | + private $searchService; |
|
59 | + |
|
60 | + |
|
61 | + /** |
|
62 | + * @since 15.0.0 |
|
63 | + * |
|
64 | + * @param IProviderService $providerService |
|
65 | + */ |
|
66 | + public function registerProviderService(IProviderService $providerService) { |
|
67 | + $this->providerService = $providerService; |
|
68 | + } |
|
69 | + |
|
70 | + /** |
|
71 | + * @since 15.0.0 |
|
72 | + * |
|
73 | + * @param IIndexService $indexService |
|
74 | + */ |
|
75 | + public function registerIndexService(IIndexService $indexService) { |
|
76 | + $this->indexService = $indexService; |
|
77 | + } |
|
78 | + |
|
79 | + /** |
|
80 | + * @since 15.0.0 |
|
81 | + * |
|
82 | + * @param ISearchService $searchService |
|
83 | + */ |
|
84 | + public function registerSearchService(ISearchService $searchService) { |
|
85 | + $this->searchService = $searchService; |
|
86 | + } |
|
87 | + |
|
88 | + /** |
|
89 | + * @since 16.0.0 |
|
90 | + * |
|
91 | + * @return bool |
|
92 | + */ |
|
93 | + public function isAvailable(): bool { |
|
94 | + if ($this->indexService === null || |
|
95 | + $this->providerService === null || |
|
96 | + $this->searchService === null) { |
|
97 | + return false; |
|
98 | + } |
|
99 | + |
|
100 | + return true; |
|
101 | + } |
|
102 | + |
|
103 | + |
|
104 | + /** |
|
105 | + * @return IProviderService |
|
106 | + * @throws FullTextSearchAppNotAvailableException |
|
107 | + */ |
|
108 | + private function getProviderService(): IProviderService { |
|
109 | + if ($this->providerService === null) { |
|
110 | + throw new FullTextSearchAppNotAvailableException('No IProviderService registered'); |
|
111 | + } |
|
112 | + |
|
113 | + return $this->providerService; |
|
114 | + } |
|
115 | + |
|
116 | + |
|
117 | + /** |
|
118 | + * @return IIndexService |
|
119 | + * @throws FullTextSearchAppNotAvailableException |
|
120 | + */ |
|
121 | + private function getIndexService(): IIndexService { |
|
122 | + if ($this->indexService === null) { |
|
123 | + throw new FullTextSearchAppNotAvailableException('No IIndexService registered'); |
|
124 | + } |
|
125 | + |
|
126 | + return $this->indexService; |
|
127 | + } |
|
128 | + |
|
129 | + |
|
130 | + /** |
|
131 | + * @return ISearchService |
|
132 | + * @throws FullTextSearchAppNotAvailableException |
|
133 | + */ |
|
134 | + private function getSearchService(): ISearchService { |
|
135 | + if ($this->searchService === null) { |
|
136 | + throw new FullTextSearchAppNotAvailableException('No ISearchService registered'); |
|
137 | + } |
|
138 | + |
|
139 | + return $this->searchService; |
|
140 | + } |
|
141 | + |
|
142 | + |
|
143 | + /** |
|
144 | + * @throws FullTextSearchAppNotAvailableException |
|
145 | + */ |
|
146 | + public function addJavascriptAPI() { |
|
147 | + $this->getProviderService()->addJavascriptAPI(); |
|
148 | + } |
|
149 | + |
|
150 | + |
|
151 | + /** |
|
152 | + * @param string $providerId |
|
153 | + * |
|
154 | + * @return bool |
|
155 | + * @throws FullTextSearchAppNotAvailableException |
|
156 | + */ |
|
157 | + public function isProviderIndexed(string $providerId): bool { |
|
158 | + return $this->getProviderService()->isProviderIndexed($providerId); |
|
159 | + } |
|
160 | + |
|
161 | + |
|
162 | + /** |
|
163 | + * @param string $providerId |
|
164 | + * @param string $documentId |
|
165 | + * @return IIndex |
|
166 | + * @throws FullTextSearchAppNotAvailableException |
|
167 | + */ |
|
168 | + public function getIndex(string $providerId, string $documentId): IIndex { |
|
169 | + return $this->getIndexService()->getIndex($providerId, $documentId); |
|
170 | + } |
|
171 | + |
|
172 | + /** |
|
173 | + * @param string $providerId |
|
174 | + * @param string $documentId |
|
175 | + * @param string $userId |
|
176 | + * @param int $status |
|
177 | + * |
|
178 | + * @see IIndex for available value for $status. |
|
179 | + * |
|
180 | + * @return IIndex |
|
181 | + * @throws FullTextSearchAppNotAvailableException |
|
182 | + */ |
|
183 | + public function createIndex(string $providerId, string $documentId, string $userId, int $status = 0): IIndex { |
|
184 | + return $this->getIndexService()->createIndex($providerId, $documentId, $userId, $status); |
|
185 | + } |
|
186 | + |
|
187 | + |
|
188 | + /** |
|
189 | + * @param string $providerId |
|
190 | + * @param string $documentId |
|
191 | + * @param int $status |
|
192 | + * @param bool $reset |
|
193 | + * |
|
194 | + * @see IIndex for available value for $status. |
|
195 | + * |
|
196 | + * @throws FullTextSearchAppNotAvailableException |
|
197 | + */ |
|
198 | + public function updateIndexStatus(string $providerId, string $documentId, int $status, bool $reset = false) { |
|
199 | + $this->getIndexService()->updateIndexStatus($providerId, $documentId, $status, $reset); |
|
200 | + } |
|
201 | + |
|
202 | + /** |
|
203 | + * @param string $providerId |
|
204 | + * @param array $documentIds |
|
205 | + * @param int $status |
|
206 | + * @param bool $reset |
|
207 | + * |
|
208 | + * @see IIndex for available value for $status. |
|
209 | + * |
|
210 | + * @throws FullTextSearchAppNotAvailableException |
|
211 | + */ |
|
212 | + public function updateIndexesStatus(string $providerId, array $documentIds, int $status, bool $reset = false) { |
|
213 | + $this->getIndexService()->updateIndexesStatus($providerId, $documentIds, $status, $reset); |
|
214 | + } |
|
215 | + |
|
216 | + |
|
217 | + /** |
|
218 | + * @param IIndex[] $indexes |
|
219 | + * |
|
220 | + * @throws FullTextSearchAppNotAvailableException |
|
221 | + */ |
|
222 | + public function updateIndexes(array $indexes) { |
|
223 | + $this->getIndexService()->updateIndexes($indexes); |
|
224 | + } |
|
225 | + |
|
226 | + |
|
227 | + /** |
|
228 | + * @param array $request |
|
229 | + * @param string $userId |
|
230 | + * |
|
231 | + * @return ISearchResult[] |
|
232 | + * @throws FullTextSearchAppNotAvailableException |
|
233 | + */ |
|
234 | + public function search(array $request, string $userId = ''): array { |
|
235 | + $searchRequest = $this->getSearchService()->generateSearchRequest($request); |
|
236 | + |
|
237 | + return $this->getSearchService()->search($userId, $searchRequest); |
|
238 | + } |
|
239 | 239 | |
240 | 240 | |
241 | 241 | } |
@@ -57,8 +57,8 @@ |
||
57 | 57 | * @deprecated 9.2.0 To implement an OCS endpoint extend the OCSController |
58 | 58 | */ |
59 | 59 | public function __construct($format, $statuscode, $message, |
60 | - $data=[], $itemscount='', |
|
61 | - $itemsperpage='') { |
|
60 | + $data = [], $itemscount = '', |
|
61 | + $itemsperpage = '') { |
|
62 | 62 | parent::__construct(); |
63 | 63 | |
64 | 64 | $this->format = $format; |
@@ -37,59 +37,59 @@ |
||
37 | 37 | * @deprecated 9.2.0 To implement an OCS endpoint extend the OCSController |
38 | 38 | */ |
39 | 39 | class OCSResponse extends Response { |
40 | - private $data; |
|
41 | - private $format; |
|
42 | - private $statuscode; |
|
43 | - private $message; |
|
44 | - private $itemscount; |
|
45 | - private $itemsperpage; |
|
40 | + private $data; |
|
41 | + private $format; |
|
42 | + private $statuscode; |
|
43 | + private $message; |
|
44 | + private $itemscount; |
|
45 | + private $itemsperpage; |
|
46 | 46 | |
47 | - /** |
|
48 | - * generates the xml or json response for the API call from an multidimenional data array. |
|
49 | - * @param string $format |
|
50 | - * @param int $statuscode |
|
51 | - * @param string $message |
|
52 | - * @param array $data |
|
53 | - * @param int|string $itemscount |
|
54 | - * @param int|string $itemsperpage |
|
55 | - * @since 8.1.0 |
|
56 | - * @deprecated 9.2.0 To implement an OCS endpoint extend the OCSController |
|
57 | - */ |
|
58 | - public function __construct($format, $statuscode, $message, |
|
59 | - $data=[], $itemscount='', |
|
60 | - $itemsperpage='') { |
|
61 | - parent::__construct(); |
|
47 | + /** |
|
48 | + * generates the xml or json response for the API call from an multidimenional data array. |
|
49 | + * @param string $format |
|
50 | + * @param int $statuscode |
|
51 | + * @param string $message |
|
52 | + * @param array $data |
|
53 | + * @param int|string $itemscount |
|
54 | + * @param int|string $itemsperpage |
|
55 | + * @since 8.1.0 |
|
56 | + * @deprecated 9.2.0 To implement an OCS endpoint extend the OCSController |
|
57 | + */ |
|
58 | + public function __construct($format, $statuscode, $message, |
|
59 | + $data=[], $itemscount='', |
|
60 | + $itemsperpage='') { |
|
61 | + parent::__construct(); |
|
62 | 62 | |
63 | - $this->format = $format; |
|
64 | - $this->statuscode = $statuscode; |
|
65 | - $this->message = $message; |
|
66 | - $this->data = $data; |
|
67 | - $this->itemscount = $itemscount; |
|
68 | - $this->itemsperpage = $itemsperpage; |
|
63 | + $this->format = $format; |
|
64 | + $this->statuscode = $statuscode; |
|
65 | + $this->message = $message; |
|
66 | + $this->data = $data; |
|
67 | + $this->itemscount = $itemscount; |
|
68 | + $this->itemsperpage = $itemsperpage; |
|
69 | 69 | |
70 | - // set the correct header based on the format parameter |
|
71 | - if ($format === 'json') { |
|
72 | - $this->addHeader( |
|
73 | - 'Content-Type', 'application/json; charset=utf-8' |
|
74 | - ); |
|
75 | - } else { |
|
76 | - $this->addHeader( |
|
77 | - 'Content-Type', 'application/xml; charset=utf-8' |
|
78 | - ); |
|
79 | - } |
|
80 | - } |
|
70 | + // set the correct header based on the format parameter |
|
71 | + if ($format === 'json') { |
|
72 | + $this->addHeader( |
|
73 | + 'Content-Type', 'application/json; charset=utf-8' |
|
74 | + ); |
|
75 | + } else { |
|
76 | + $this->addHeader( |
|
77 | + 'Content-Type', 'application/xml; charset=utf-8' |
|
78 | + ); |
|
79 | + } |
|
80 | + } |
|
81 | 81 | |
82 | - /** |
|
83 | - * @return string |
|
84 | - * @since 8.1.0 |
|
85 | - * @deprecated 9.2.0 To implement an OCS endpoint extend the OCSController |
|
86 | - * @suppress PhanDeprecatedClass |
|
87 | - */ |
|
88 | - public function render() { |
|
89 | - $r = new \OC\OCS\Result($this->data, $this->statuscode, $this->message); |
|
90 | - $r->setTotalItems($this->itemscount); |
|
91 | - $r->setItemsPerPage($this->itemsperpage); |
|
82 | + /** |
|
83 | + * @return string |
|
84 | + * @since 8.1.0 |
|
85 | + * @deprecated 9.2.0 To implement an OCS endpoint extend the OCSController |
|
86 | + * @suppress PhanDeprecatedClass |
|
87 | + */ |
|
88 | + public function render() { |
|
89 | + $r = new \OC\OCS\Result($this->data, $this->statuscode, $this->message); |
|
90 | + $r->setTotalItems($this->itemscount); |
|
91 | + $r->setItemsPerPage($this->itemsperpage); |
|
92 | 92 | |
93 | - return \OC_API::renderResult($this->format, $r->getMeta(), $r->getData()); |
|
94 | - } |
|
93 | + return \OC_API::renderResult($this->format, $r->getMeta(), $r->getData()); |
|
94 | + } |
|
95 | 95 | } |
@@ -34,56 +34,56 @@ |
||
34 | 34 | * @since 15.0.0 |
35 | 35 | */ |
36 | 36 | class ZipResponse extends Response implements ICallbackResponse { |
37 | - /** @var resource[] Files to be added to the zip response */ |
|
38 | - private $resources; |
|
39 | - /** @var string Filename that the zip file should have */ |
|
40 | - private $name; |
|
41 | - private $request; |
|
37 | + /** @var resource[] Files to be added to the zip response */ |
|
38 | + private $resources; |
|
39 | + /** @var string Filename that the zip file should have */ |
|
40 | + private $name; |
|
41 | + private $request; |
|
42 | 42 | |
43 | - /** |
|
44 | - * @since 15.0.0 |
|
45 | - */ |
|
46 | - public function __construct(IRequest $request, string $name = 'output') { |
|
47 | - parent::__construct(); |
|
43 | + /** |
|
44 | + * @since 15.0.0 |
|
45 | + */ |
|
46 | + public function __construct(IRequest $request, string $name = 'output') { |
|
47 | + parent::__construct(); |
|
48 | 48 | |
49 | - $this->name = $name; |
|
50 | - $this->request = $request; |
|
51 | - } |
|
49 | + $this->name = $name; |
|
50 | + $this->request = $request; |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * @since 15.0.0 |
|
55 | - */ |
|
56 | - public function addResource($r, string $internalName, int $size, int $time = -1) { |
|
57 | - if (!\is_resource($r)) { |
|
58 | - throw new \InvalidArgumentException('No resource provided'); |
|
59 | - } |
|
53 | + /** |
|
54 | + * @since 15.0.0 |
|
55 | + */ |
|
56 | + public function addResource($r, string $internalName, int $size, int $time = -1) { |
|
57 | + if (!\is_resource($r)) { |
|
58 | + throw new \InvalidArgumentException('No resource provided'); |
|
59 | + } |
|
60 | 60 | |
61 | - $this->resources[] = [ |
|
62 | - 'resource' => $r, |
|
63 | - 'internalName' => $internalName, |
|
64 | - 'size' => $size, |
|
65 | - 'time' => $time, |
|
66 | - ]; |
|
67 | - } |
|
61 | + $this->resources[] = [ |
|
62 | + 'resource' => $r, |
|
63 | + 'internalName' => $internalName, |
|
64 | + 'size' => $size, |
|
65 | + 'time' => $time, |
|
66 | + ]; |
|
67 | + } |
|
68 | 68 | |
69 | - /** |
|
70 | - * @since 15.0.0 |
|
71 | - */ |
|
72 | - public function callback(IOutput $output) { |
|
73 | - $size = 0; |
|
74 | - $files = count($this->resources); |
|
69 | + /** |
|
70 | + * @since 15.0.0 |
|
71 | + */ |
|
72 | + public function callback(IOutput $output) { |
|
73 | + $size = 0; |
|
74 | + $files = count($this->resources); |
|
75 | 75 | |
76 | - foreach ($this->resources as $resource) { |
|
77 | - $size += $resource['size']; |
|
78 | - } |
|
76 | + foreach ($this->resources as $resource) { |
|
77 | + $size += $resource['size']; |
|
78 | + } |
|
79 | 79 | |
80 | - $zip = new Streamer($this->request, $size, $files); |
|
81 | - $zip->sendHeaders($this->name); |
|
80 | + $zip = new Streamer($this->request, $size, $files); |
|
81 | + $zip->sendHeaders($this->name); |
|
82 | 82 | |
83 | - foreach ($this->resources as $resource) { |
|
84 | - $zip->addFileFromStream($resource['resource'], $resource['internalName'], $resource['size'], $resource['time']); |
|
85 | - } |
|
83 | + foreach ($this->resources as $resource) { |
|
84 | + $zip->addFileFromStream($resource['resource'], $resource['internalName'], $resource['size'], $resource['time']); |
|
85 | + } |
|
86 | 86 | |
87 | - $zip->finalize(); |
|
88 | - } |
|
87 | + $zip->finalize(); |
|
88 | + } |
|
89 | 89 | } |
@@ -32,40 +32,40 @@ |
||
32 | 32 | */ |
33 | 33 | class FileDisplayResponse extends Response implements ICallbackResponse { |
34 | 34 | |
35 | - /** @var \OCP\Files\File|\OCP\Files\SimpleFS\ISimpleFile */ |
|
36 | - private $file; |
|
35 | + /** @var \OCP\Files\File|\OCP\Files\SimpleFS\ISimpleFile */ |
|
36 | + private $file; |
|
37 | 37 | |
38 | - /** |
|
39 | - * FileDisplayResponse constructor. |
|
40 | - * |
|
41 | - * @param \OCP\Files\File|\OCP\Files\SimpleFS\ISimpleFile $file |
|
42 | - * @param int $statusCode |
|
43 | - * @param array $headers |
|
44 | - * @since 11.0.0 |
|
45 | - */ |
|
46 | - public function __construct($file, $statusCode=Http::STATUS_OK, |
|
47 | - $headers=[]) { |
|
48 | - parent::__construct(); |
|
38 | + /** |
|
39 | + * FileDisplayResponse constructor. |
|
40 | + * |
|
41 | + * @param \OCP\Files\File|\OCP\Files\SimpleFS\ISimpleFile $file |
|
42 | + * @param int $statusCode |
|
43 | + * @param array $headers |
|
44 | + * @since 11.0.0 |
|
45 | + */ |
|
46 | + public function __construct($file, $statusCode=Http::STATUS_OK, |
|
47 | + $headers=[]) { |
|
48 | + parent::__construct(); |
|
49 | 49 | |
50 | - $this->file = $file; |
|
51 | - $this->setStatus($statusCode); |
|
52 | - $this->setHeaders(array_merge($this->getHeaders(), $headers)); |
|
53 | - $this->addHeader('Content-Disposition', 'inline; filename="' . rawurldecode($file->getName()) . '"'); |
|
50 | + $this->file = $file; |
|
51 | + $this->setStatus($statusCode); |
|
52 | + $this->setHeaders(array_merge($this->getHeaders(), $headers)); |
|
53 | + $this->addHeader('Content-Disposition', 'inline; filename="' . rawurldecode($file->getName()) . '"'); |
|
54 | 54 | |
55 | - $this->setETag($file->getEtag()); |
|
56 | - $lastModified = new \DateTime(); |
|
57 | - $lastModified->setTimestamp($file->getMTime()); |
|
58 | - $this->setLastModified($lastModified); |
|
59 | - } |
|
55 | + $this->setETag($file->getEtag()); |
|
56 | + $lastModified = new \DateTime(); |
|
57 | + $lastModified->setTimestamp($file->getMTime()); |
|
58 | + $this->setLastModified($lastModified); |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * @param IOutput $output |
|
63 | - * @since 11.0.0 |
|
64 | - */ |
|
65 | - public function callback(IOutput $output) { |
|
66 | - if ($output->getHttpResponseCode() !== Http::STATUS_NOT_MODIFIED) { |
|
67 | - $output->setHeader('Content-Length: ' . $this->file->getSize()); |
|
68 | - $output->setOutput($this->file->getContent()); |
|
69 | - } |
|
70 | - } |
|
61 | + /** |
|
62 | + * @param IOutput $output |
|
63 | + * @since 11.0.0 |
|
64 | + */ |
|
65 | + public function callback(IOutput $output) { |
|
66 | + if ($output->getHttpResponseCode() !== Http::STATUS_NOT_MODIFIED) { |
|
67 | + $output->setHeader('Content-Length: ' . $this->file->getSize()); |
|
68 | + $output->setOutput($this->file->getContent()); |
|
69 | + } |
|
70 | + } |
|
71 | 71 | } |
@@ -43,14 +43,14 @@ discard block |
||
43 | 43 | * @param array $headers |
44 | 44 | * @since 11.0.0 |
45 | 45 | */ |
46 | - public function __construct($file, $statusCode=Http::STATUS_OK, |
|
47 | - $headers=[]) { |
|
46 | + public function __construct($file, $statusCode = Http::STATUS_OK, |
|
47 | + $headers = []) { |
|
48 | 48 | parent::__construct(); |
49 | 49 | |
50 | 50 | $this->file = $file; |
51 | 51 | $this->setStatus($statusCode); |
52 | 52 | $this->setHeaders(array_merge($this->getHeaders(), $headers)); |
53 | - $this->addHeader('Content-Disposition', 'inline; filename="' . rawurldecode($file->getName()) . '"'); |
|
53 | + $this->addHeader('Content-Disposition', 'inline; filename="'.rawurldecode($file->getName()).'"'); |
|
54 | 54 | |
55 | 55 | $this->setETag($file->getEtag()); |
56 | 56 | $lastModified = new \DateTime(); |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | */ |
65 | 65 | public function callback(IOutput $output) { |
66 | 66 | if ($output->getHttpResponseCode() !== Http::STATUS_NOT_MODIFIED) { |
67 | - $output->setHeader('Content-Length: ' . $this->file->getSize()); |
|
67 | + $output->setHeader('Content-Length: '.$this->file->getSize()); |
|
68 | 68 | $output->setOutput($this->file->getContent()); |
69 | 69 | } |
70 | 70 | } |
@@ -33,106 +33,106 @@ |
||
33 | 33 | use OpenStack\Common\Error\BadResponseError; |
34 | 34 | |
35 | 35 | class Swift implements IObjectStore { |
36 | - /** |
|
37 | - * @var array |
|
38 | - */ |
|
39 | - private $params; |
|
40 | - |
|
41 | - /** @var SwiftFactory */ |
|
42 | - private $swiftFactory; |
|
43 | - |
|
44 | - public function __construct($params, SwiftFactory $connectionFactory = null) { |
|
45 | - $this->swiftFactory = $connectionFactory ?: new SwiftFactory( |
|
46 | - \OC::$server->getMemCacheFactory()->createDistributed('swift::'), |
|
47 | - $params, |
|
48 | - \OC::$server->getLogger() |
|
49 | - ); |
|
50 | - $this->params = $params; |
|
51 | - } |
|
52 | - |
|
53 | - /** |
|
54 | - * @return \OpenStack\ObjectStore\v1\Models\Container |
|
55 | - * @throws StorageAuthException |
|
56 | - * @throws \OCP\Files\StorageNotAvailableException |
|
57 | - */ |
|
58 | - private function getContainer() { |
|
59 | - return $this->swiftFactory->getContainer(); |
|
60 | - } |
|
61 | - |
|
62 | - /** |
|
63 | - * @return string the container name where objects are stored |
|
64 | - */ |
|
65 | - public function getStorageId() { |
|
66 | - if (isset($this->params['bucket'])) { |
|
67 | - return $this->params['bucket']; |
|
68 | - } |
|
69 | - |
|
70 | - return $this->params['container']; |
|
71 | - } |
|
72 | - |
|
73 | - /** |
|
74 | - * @param string $urn the unified resource name used to identify the object |
|
75 | - * @param resource $stream stream with the data to write |
|
76 | - * @throws \Exception from openstack lib when something goes wrong |
|
77 | - */ |
|
78 | - public function writeObject($urn, $stream) { |
|
79 | - $tmpFile = \OC::$server->getTempManager()->getTemporaryFile('swiftwrite'); |
|
80 | - file_put_contents($tmpFile, $stream); |
|
81 | - $handle = fopen($tmpFile, 'rb'); |
|
82 | - |
|
83 | - $this->getContainer()->createObject([ |
|
84 | - 'name' => $urn, |
|
85 | - 'stream' => stream_for($handle) |
|
86 | - ]); |
|
87 | - } |
|
88 | - |
|
89 | - /** |
|
90 | - * @param string $urn the unified resource name used to identify the object |
|
91 | - * @return resource stream with the read data |
|
92 | - * @throws \Exception from openstack lib when something goes wrong |
|
93 | - * @throws NotFoundException if file does not exist |
|
94 | - */ |
|
95 | - public function readObject($urn) { |
|
96 | - try { |
|
97 | - $object = $this->getContainer()->getObject($urn); |
|
98 | - |
|
99 | - // we need to keep a reference to objectContent or |
|
100 | - // the stream will be closed before we can do anything with it |
|
101 | - $objectContent = $object->download(); |
|
102 | - } catch (BadResponseError $e) { |
|
103 | - if ($e->getResponse()->getStatusCode() === 404) { |
|
104 | - throw new NotFoundException("object $urn not found in object store"); |
|
105 | - } else { |
|
106 | - throw $e; |
|
107 | - } |
|
108 | - } |
|
109 | - $objectContent->rewind(); |
|
110 | - |
|
111 | - $stream = $objectContent->detach(); |
|
112 | - // save the object content in the context of the stream to prevent it being gc'd until the stream is closed |
|
113 | - stream_context_set_option($stream, 'swift', 'content', $objectContent); |
|
114 | - |
|
115 | - return RetryWrapper::wrap($stream); |
|
116 | - } |
|
117 | - |
|
118 | - /** |
|
119 | - * @param string $urn Unified Resource Name |
|
120 | - * @return void |
|
121 | - * @throws \Exception from openstack lib when something goes wrong |
|
122 | - */ |
|
123 | - public function deleteObject($urn) { |
|
124 | - $this->getContainer()->getObject($urn)->delete(); |
|
125 | - } |
|
126 | - |
|
127 | - /** |
|
128 | - * @return void |
|
129 | - * @throws \Exception from openstack lib when something goes wrong |
|
130 | - */ |
|
131 | - public function deleteContainer() { |
|
132 | - $this->getContainer()->delete(); |
|
133 | - } |
|
134 | - |
|
135 | - public function objectExists($urn) { |
|
136 | - return $this->getContainer()->objectExists($urn); |
|
137 | - } |
|
36 | + /** |
|
37 | + * @var array |
|
38 | + */ |
|
39 | + private $params; |
|
40 | + |
|
41 | + /** @var SwiftFactory */ |
|
42 | + private $swiftFactory; |
|
43 | + |
|
44 | + public function __construct($params, SwiftFactory $connectionFactory = null) { |
|
45 | + $this->swiftFactory = $connectionFactory ?: new SwiftFactory( |
|
46 | + \OC::$server->getMemCacheFactory()->createDistributed('swift::'), |
|
47 | + $params, |
|
48 | + \OC::$server->getLogger() |
|
49 | + ); |
|
50 | + $this->params = $params; |
|
51 | + } |
|
52 | + |
|
53 | + /** |
|
54 | + * @return \OpenStack\ObjectStore\v1\Models\Container |
|
55 | + * @throws StorageAuthException |
|
56 | + * @throws \OCP\Files\StorageNotAvailableException |
|
57 | + */ |
|
58 | + private function getContainer() { |
|
59 | + return $this->swiftFactory->getContainer(); |
|
60 | + } |
|
61 | + |
|
62 | + /** |
|
63 | + * @return string the container name where objects are stored |
|
64 | + */ |
|
65 | + public function getStorageId() { |
|
66 | + if (isset($this->params['bucket'])) { |
|
67 | + return $this->params['bucket']; |
|
68 | + } |
|
69 | + |
|
70 | + return $this->params['container']; |
|
71 | + } |
|
72 | + |
|
73 | + /** |
|
74 | + * @param string $urn the unified resource name used to identify the object |
|
75 | + * @param resource $stream stream with the data to write |
|
76 | + * @throws \Exception from openstack lib when something goes wrong |
|
77 | + */ |
|
78 | + public function writeObject($urn, $stream) { |
|
79 | + $tmpFile = \OC::$server->getTempManager()->getTemporaryFile('swiftwrite'); |
|
80 | + file_put_contents($tmpFile, $stream); |
|
81 | + $handle = fopen($tmpFile, 'rb'); |
|
82 | + |
|
83 | + $this->getContainer()->createObject([ |
|
84 | + 'name' => $urn, |
|
85 | + 'stream' => stream_for($handle) |
|
86 | + ]); |
|
87 | + } |
|
88 | + |
|
89 | + /** |
|
90 | + * @param string $urn the unified resource name used to identify the object |
|
91 | + * @return resource stream with the read data |
|
92 | + * @throws \Exception from openstack lib when something goes wrong |
|
93 | + * @throws NotFoundException if file does not exist |
|
94 | + */ |
|
95 | + public function readObject($urn) { |
|
96 | + try { |
|
97 | + $object = $this->getContainer()->getObject($urn); |
|
98 | + |
|
99 | + // we need to keep a reference to objectContent or |
|
100 | + // the stream will be closed before we can do anything with it |
|
101 | + $objectContent = $object->download(); |
|
102 | + } catch (BadResponseError $e) { |
|
103 | + if ($e->getResponse()->getStatusCode() === 404) { |
|
104 | + throw new NotFoundException("object $urn not found in object store"); |
|
105 | + } else { |
|
106 | + throw $e; |
|
107 | + } |
|
108 | + } |
|
109 | + $objectContent->rewind(); |
|
110 | + |
|
111 | + $stream = $objectContent->detach(); |
|
112 | + // save the object content in the context of the stream to prevent it being gc'd until the stream is closed |
|
113 | + stream_context_set_option($stream, 'swift', 'content', $objectContent); |
|
114 | + |
|
115 | + return RetryWrapper::wrap($stream); |
|
116 | + } |
|
117 | + |
|
118 | + /** |
|
119 | + * @param string $urn Unified Resource Name |
|
120 | + * @return void |
|
121 | + * @throws \Exception from openstack lib when something goes wrong |
|
122 | + */ |
|
123 | + public function deleteObject($urn) { |
|
124 | + $this->getContainer()->getObject($urn)->delete(); |
|
125 | + } |
|
126 | + |
|
127 | + /** |
|
128 | + * @return void |
|
129 | + * @throws \Exception from openstack lib when something goes wrong |
|
130 | + */ |
|
131 | + public function deleteContainer() { |
|
132 | + $this->getContainer()->delete(); |
|
133 | + } |
|
134 | + |
|
135 | + public function objectExists($urn) { |
|
136 | + return $this->getContainer()->objectExists($urn); |
|
137 | + } |
|
138 | 138 | } |
@@ -34,20 +34,20 @@ |
||
34 | 34 | * @method void setHashedCode(string $token) |
35 | 35 | */ |
36 | 36 | class AccessToken extends Entity { |
37 | - /** @var int */ |
|
38 | - protected $tokenId; |
|
39 | - /** @var int */ |
|
40 | - protected $clientId; |
|
41 | - /** @var string */ |
|
42 | - protected $hashedCode; |
|
43 | - /** @var string */ |
|
44 | - protected $encryptedToken; |
|
37 | + /** @var int */ |
|
38 | + protected $tokenId; |
|
39 | + /** @var int */ |
|
40 | + protected $clientId; |
|
41 | + /** @var string */ |
|
42 | + protected $hashedCode; |
|
43 | + /** @var string */ |
|
44 | + protected $encryptedToken; |
|
45 | 45 | |
46 | - public function __construct() { |
|
47 | - $this->addType('id', 'int'); |
|
48 | - $this->addType('tokenId', 'int'); |
|
49 | - $this->addType('clientId', 'int'); |
|
50 | - $this->addType('hashedCode', 'string'); |
|
51 | - $this->addType('encryptedToken', 'string'); |
|
52 | - } |
|
46 | + public function __construct() { |
|
47 | + $this->addType('id', 'int'); |
|
48 | + $this->addType('tokenId', 'int'); |
|
49 | + $this->addType('clientId', 'int'); |
|
50 | + $this->addType('hashedCode', 'string'); |
|
51 | + $this->addType('encryptedToken', 'string'); |
|
52 | + } |
|
53 | 53 | } |