This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | namespace Dkd\PhpCmis\Bindings\Browser; |
||
3 | |||
4 | /* |
||
5 | * This file is part of php-cmis-client. |
||
6 | * |
||
7 | * (c) Sascha Egerer <[email protected]> |
||
8 | * |
||
9 | * For the full copyright and license information, please view the LICENSE |
||
10 | * file that was distributed with this source code. |
||
11 | */ |
||
12 | |||
13 | use Dkd\PhpCmis\Constants; |
||
14 | use Dkd\PhpCmis\Data\AclInterface; |
||
15 | use Dkd\PhpCmis\Data\AllowableActionsInterface; |
||
16 | use Dkd\PhpCmis\Data\BulkUpdateObjectIdAndChangeTokenInterface; |
||
17 | use Dkd\PhpCmis\Data\ExtensionDataInterface; |
||
18 | use Dkd\PhpCmis\Data\FailedToDeleteDataInterface; |
||
19 | use Dkd\PhpCmis\Data\ObjectDataInterface; |
||
20 | use Dkd\PhpCmis\Data\PropertiesInterface; |
||
21 | use Dkd\PhpCmis\Data\RenditionDataInterface; |
||
22 | use Dkd\PhpCmis\Enum\IncludeRelationships; |
||
23 | use Dkd\PhpCmis\Enum\UnfileObject; |
||
24 | use Dkd\PhpCmis\Enum\VersioningState; |
||
25 | use Dkd\PhpCmis\Exception\CmisInvalidArgumentException; |
||
26 | use Dkd\PhpCmis\ObjectServiceInterface; |
||
27 | use Dkd\PhpCmis\PropertyIds; |
||
28 | use Dkd\PhpCmis\SessionParameter; |
||
29 | use Guzzle\Http\Message\Response; |
||
30 | use GuzzleHttp\Stream\LimitStream; |
||
31 | use GuzzleHttp\Stream\StreamInterface; |
||
32 | |||
33 | /** |
||
34 | * Object Service Browser Binding client. |
||
35 | */ |
||
36 | class ObjectService extends AbstractBrowserBindingService implements ObjectServiceInterface |
||
37 | { |
||
38 | /** |
||
39 | * L1 cache for objects. Fills with two levels: |
||
40 | * |
||
41 | * - First level key is the object ID, path or other singular identifier of object(s) |
||
42 | * - Second level key is a hash of context arguments used to retrieve the object(s) |
||
43 | * |
||
44 | * @var array |
||
45 | */ |
||
46 | protected $objectCache = []; |
||
47 | |||
48 | /** |
||
49 | * Appends the content stream to the content of the document. |
||
50 | * |
||
51 | * The stream in contentStream is consumed but not closed by this method. |
||
52 | * |
||
53 | * @param string $repositoryId the identifier for the repository |
||
54 | * @param string $objectId The identifier for the object. The repository might return a different/new object id |
||
55 | * @param StreamInterface $contentStream The content stream to append |
||
56 | * @param boolean $isLastChunk Indicates if this content stream is the last chunk |
||
57 | * @param string|null $changeToken The last change token of this object that the client received. |
||
58 | * The repository might return a new change token (default is <code>null</code>) |
||
59 | * @param ExtensionDataInterface|null $extension |
||
60 | */ |
||
61 | public function appendContentStream( |
||
62 | $repositoryId, |
||
63 | & $objectId, |
||
64 | StreamInterface $contentStream, |
||
65 | $isLastChunk, |
||
66 | & $changeToken = null, |
||
67 | ExtensionDataInterface $extension = null |
||
68 | ) { |
||
69 | // TODO: Implement appendContentStream() method. |
||
70 | } |
||
71 | |||
72 | /** |
||
73 | * Updates properties and secondary types of one or more objects. |
||
74 | * |
||
75 | * @param string $repositoryId the identifier for the repository |
||
76 | * @param BulkUpdateObjectIdAndChangeTokenInterface[] $objectIdsAndChangeTokens |
||
77 | * @param PropertiesInterface $properties |
||
78 | * @param string[] $addSecondaryTypeIds the secondary types to apply |
||
79 | * @param string[] $removeSecondaryTypeIds the secondary types to remove |
||
80 | * @param ExtensionDataInterface|null $extension |
||
81 | * @return BulkUpdateObjectIdAndChangeTokenInterface[] |
||
82 | */ |
||
83 | public function bulkUpdateProperties( |
||
84 | $repositoryId, |
||
85 | array $objectIdsAndChangeTokens, |
||
86 | PropertiesInterface $properties, |
||
87 | array $addSecondaryTypeIds, |
||
88 | array $removeSecondaryTypeIds, |
||
89 | ExtensionDataInterface $extension = null |
||
90 | ) { |
||
91 | // TODO: Implement bulkUpdateProperties() method. |
||
92 | } |
||
93 | |||
94 | /** |
||
95 | * @param string $action |
||
96 | * @param PropertiesInterface $properties |
||
97 | * @param string[] $policies |
||
98 | * @param AclInterface $addAces |
||
99 | * @param AclInterface $removeAces |
||
100 | * @param ExtensionDataInterface $extension |
||
101 | * @return array |
||
102 | */ |
||
103 | protected function createQueryArray( |
||
104 | 9 | $action, |
|
105 | PropertiesInterface $properties, |
||
106 | array $policies = [], |
||
107 | AclInterface $addAces = null, |
||
108 | AclInterface $removeAces = null, |
||
109 | ExtensionDataInterface $extension = null |
||
0 ignored issues
–
show
|
|||
110 | ) { |
||
111 | $queryArray = array_replace( |
||
112 | 9 | [ |
|
113 | Constants::CONTROL_CMISACTION => $action, |
||
114 | 9 | Constants::PARAM_SUCCINCT => $this->getSuccinct() ? 'true' : 'false', |
|
115 | 9 | ], |
|
116 | 9 | $this->convertPropertiesToQueryArray($properties), |
|
117 | 9 | $this->convertPolicyIdArrayToQueryArray($policies) |
|
118 | 9 | ); |
|
119 | 9 | View Code Duplication | if (!empty($removeAces)) { |
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
120 | 9 | $queryArray = array_replace($queryArray, $this->convertAclToQueryArray( |
|
121 | 5 | $removeAces, |
|
122 | 5 | Constants::CONTROL_REMOVE_ACE_PRINCIPAL, |
|
123 | 5 | Constants::CONTROL_REMOVE_ACE_PERMISSION |
|
124 | )); |
||
125 | 5 | } |
|
126 | 5 | View Code Duplication | if (!empty($addAces)) { |
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
127 | 9 | $queryArray = array_replace($queryArray, $this->convertAclToQueryArray( |
|
128 | 5 | $addAces, |
|
129 | 5 | Constants::CONTROL_ADD_ACE_PRINCIPAL, |
|
130 | 5 | Constants::CONTROL_ADD_ACE_PERMISSION |
|
131 | )); |
||
132 | 5 | } |
|
133 | 5 | return $queryArray; |
|
134 | 9 | } |
|
135 | |||
136 | /** |
||
137 | * Creates a document object of the specified type (given by the cmis:objectTypeId property) |
||
138 | * in the (optionally) specified location. |
||
139 | * |
||
140 | * @param string $repositoryId the identifier for the repository |
||
141 | * @param PropertiesInterface $properties the property values that must be applied to the newly |
||
142 | * created document object |
||
143 | * @param string|null $folderId if specified, the identifier for the folder that must be the parent |
||
144 | * folder for the newly created document object |
||
145 | * @param StreamInterface|null $contentStream the content stream that must be stored for the newly |
||
146 | * created document object |
||
147 | * @param VersioningState|null $versioningState specifies what the versioning state of the newly created object |
||
148 | * must be (default is <code>VersioningState::MAJOR</code>) |
||
149 | * @param string[] $policies a list of policy IDs that must be applied to the newly created document object |
||
150 | * @param AclInterface|null $addAces a list of ACEs that must be added to the newly created document object, |
||
151 | * either using the ACL from folderId if specified, or being applied if no folderId is specified |
||
152 | * @param AclInterface|null $removeAces a list of ACEs that must be removed from the newly created document object, |
||
153 | * either using the ACL from folderId if specified, or being ignored if no folderId is specified |
||
154 | * @param ExtensionDataInterface|null $extension |
||
155 | * @return string|null Returns the new object id or <code>null</code> if the repository sent an empty |
||
156 | * result (which should not happen) |
||
157 | */ |
||
158 | public function createDocument( |
||
159 | 3 | $repositoryId, |
|
160 | PropertiesInterface $properties, |
||
161 | $folderId = null, |
||
162 | StreamInterface $contentStream = null, |
||
163 | VersioningState $versioningState = null, |
||
164 | array $policies = [], |
||
165 | AclInterface $addAces = null, |
||
166 | AclInterface $removeAces = null, |
||
167 | ExtensionDataInterface $extension = null |
||
168 | ) { |
||
169 | View Code Duplication | if ($folderId === null) { |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
170 | 3 | $url = $this->getRepositoryUrl($repositoryId); |
|
171 | 1 | } else { |
|
172 | 1 | $url = $this->getObjectUrl($repositoryId, $folderId); |
|
173 | 2 | } |
|
174 | |||
175 | $queryArray = $this->createQueryArray( |
||
176 | 3 | Constants::CMISACTION_CREATE_DOCUMENT, |
|
177 | 3 | $properties, |
|
178 | 3 | $policies, |
|
179 | 3 | $addAces, |
|
180 | 3 | $removeAces, |
|
181 | 3 | $extension |
|
182 | ); |
||
183 | 3 | if ($versioningState !== null) { |
|
184 | 3 | $queryArray[Constants::PARAM_VERSIONING_STATE] = (string) $versioningState; |
|
185 | 2 | } |
|
186 | 2 | ||
187 | if ($contentStream) { |
||
188 | 3 | $queryArray['content'] = $contentStream; |
|
189 | 3 | } |
|
190 | 3 | ||
191 | 3 | $newObject = $this->getJsonConverter()->convertObject( |
|
192 | 3 | (array) $this->postJson( |
|
193 | 3 | $url, |
|
194 | 3 | $queryArray |
|
195 | 3 | ) |
|
196 | ); |
||
197 | 3 | ||
198 | if ($newObject) { |
||
199 | 3 | $newObjectId = $newObject->getId(); |
|
200 | return $newObjectId; |
||
201 | 3 | } |
|
202 | 3 | return null; |
|
203 | 3 | } |
|
204 | 2 | ||
205 | 2 | /** |
|
206 | 3 | * Creates a document object as a copy of the given source document in the (optionally) specified location. |
|
207 | * |
||
208 | * @param string $repositoryId the identifier for the repository |
||
209 | * @param string $sourceId the identifier for the source document |
||
210 | * @param PropertiesInterface $properties the property values that must be applied to the newly |
||
211 | * created document object |
||
212 | * @param string|null $folderId if specified, the identifier for the folder that must be the parent folder for the |
||
213 | * newly created document object |
||
214 | * @param VersioningState|null $versioningState specifies what the versioning state of the newly created object |
||
215 | * must be (default is <code>VersioningState::MAJOR</code>) |
||
216 | * @param string[] $policies a list of policy IDs that must be applied to the newly created document object |
||
217 | * @param AclInterface|null $addAces a list of ACEs that must be added to the newly created document object, |
||
218 | * either using the ACL from folderId if specified, or being applied if no folderId is specified |
||
219 | * @param AclInterface|null $removeAces a list of ACEs that must be removed from the newly created document object, |
||
220 | * either using the ACL from folderId if specified, or being ignored if no folderId is specified |
||
221 | * @param ExtensionDataInterface|null $extension |
||
222 | * @return string|null Returns the new object id or <code>null</code> if the repository sent an empty |
||
223 | * result (which should not happen) |
||
224 | */ |
||
225 | public function createDocumentFromSource( |
||
226 | $repositoryId, |
||
227 | $sourceId, |
||
228 | PropertiesInterface $properties, |
||
229 | $folderId = null, |
||
230 | VersioningState $versioningState = null, |
||
231 | 2 | array $policies = [], |
|
232 | AclInterface $addAces = null, |
||
233 | AclInterface $removeAces = null, |
||
234 | ExtensionDataInterface $extension = null |
||
235 | ) { |
||
236 | View Code Duplication | if ($folderId === null) { |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
237 | $url = $this->getRepositoryUrl($repositoryId); |
||
238 | } else { |
||
239 | $url = $this->getObjectUrl($repositoryId, $folderId); |
||
240 | } |
||
241 | |||
242 | 2 | $queryArray = $this->createQueryArray( |
|
243 | Constants::CMISACTION_CREATE_DOCUMENT_FROM_SOURCE, |
||
244 | $properties, |
||
245 | 2 | $policies, |
|
246 | $addAces, |
||
247 | $removeAces, |
||
248 | 2 | $extension |
|
249 | 2 | ); |
|
250 | 2 | $queryArray[Constants::PARAM_SOURCE_ID] = (string) $sourceId; |
|
251 | 2 | if ($versioningState !== null) { |
|
252 | 2 | $queryArray[Constants::PARAM_VERSIONING_STATE] = (string) $versioningState; |
|
253 | 2 | } |
|
254 | |||
255 | 2 | $newObject = $this->getJsonConverter()->convertObject((array) $this->postJson($url, $queryArray)); |
|
256 | 2 | ||
257 | 2 | return ($newObject === null) ? null : $newObject->getId(); |
|
258 | 1 | } |
|
259 | 1 | ||
260 | 2 | /** |
|
261 | * Creates a folder object of the specified type (given by the cmis:objectTypeId property) in |
||
262 | 2 | * the specified location. |
|
263 | * |
||
264 | 2 | * @param string $repositoryId the identifier for the repository |
|
265 | * @param PropertiesInterface $properties the property values that must be applied to the newly |
||
266 | * created document object |
||
267 | * @param string $folderId if specified, the identifier for the folder that must be the parent folder for the |
||
268 | * newly created document object |
||
269 | * @param string[] $policies a list of policy IDs that must be applied to the newly created document object |
||
270 | * @param AclInterface|null $addAces a list of ACEs that must be added to the newly created document object, |
||
271 | * either using the ACL from folderId if specified, or being applied if no folderId is specified |
||
272 | * @param AclInterface|null $removeAces a list of ACEs that must be removed from the newly created document object, |
||
273 | * either using the ACL from folderId if specified, or being ignored if no folderId is specified |
||
274 | * @param ExtensionDataInterface|null $extension |
||
275 | * @return string|null Returns the new object id or <code>null</code> if the repository sent an empty |
||
276 | * result (which should not happen) |
||
277 | */ |
||
278 | View Code Duplication | public function createFolder( |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
279 | $repositoryId, |
||
280 | PropertiesInterface $properties, |
||
281 | $folderId, |
||
282 | array $policies = [], |
||
283 | AclInterface $addAces = null, |
||
284 | AclInterface $removeAces = null, |
||
285 | 2 | ExtensionDataInterface $extension = null |
|
286 | ) { |
||
287 | $url = $this->getObjectUrl($repositoryId, $folderId); |
||
288 | $queryArray = $this->createQueryArray( |
||
289 | Constants::CMISACTION_CREATE_FOLDER, |
||
290 | $properties, |
||
291 | $policies, |
||
292 | $addAces, |
||
293 | $removeAces, |
||
294 | 2 | $extension |
|
295 | 2 | ); |
|
296 | 2 | ||
297 | 2 | $newObject = $this->getJsonConverter()->convertObject((array) $this->postJson($url, $queryArray)); |
|
298 | 2 | ||
299 | 2 | return ($newObject === null) ? null : $newObject->getId(); |
|
300 | 2 | } |
|
301 | |||
302 | 2 | /** |
|
303 | * Creates an item object of the specified type (given by the cmis:objectTypeId property). |
||
304 | 2 | * |
|
305 | * @param string $repositoryId The identifier for the repository |
||
306 | 2 | * @param PropertiesInterface $properties The property values that must be applied to the newly |
|
307 | * created document object |
||
308 | 2 | * @param string|null $folderId If specified, the identifier for the folder that must be the parent folder for the |
|
309 | * newly created document object |
||
310 | * @param string[] $policies A list of policy IDs that must be applied to the newly created document object |
||
311 | * @param AclInterface|null $addAces A list of ACEs that must be added to the newly created document object, |
||
312 | * either using the ACL from folderId if specified, or being applied if no folderId is specified |
||
313 | * @param AclInterface|null $removeAces A list of ACEs that must be removed from the newly created document object, |
||
314 | * either using the ACL from folderId if specified, or being ignored if no folderId is specified |
||
315 | * @param ExtensionDataInterface|null $extension |
||
316 | * @return string|null Returns the new item id or <code>null</code> if the repository sent an empty |
||
317 | * result (which should not happen) |
||
318 | */ |
||
319 | public function createItem( |
||
320 | $repositoryId, |
||
321 | PropertiesInterface $properties, |
||
322 | $folderId = null, |
||
323 | array $policies = [], |
||
324 | AclInterface $addAces = null, |
||
325 | AclInterface $removeAces = null, |
||
326 | ExtensionDataInterface $extension = null |
||
327 | ) { |
||
328 | 2 | View Code Duplication | if ($folderId === null) { |
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
329 | $url = $this->getRepositoryUrl($repositoryId); |
||
330 | } else { |
||
331 | $url = $this->getObjectUrl($repositoryId, $folderId); |
||
332 | } |
||
333 | |||
334 | $queryArray = $this->createQueryArray( |
||
335 | Constants::CMISACTION_CREATE_ITEM, |
||
336 | $properties, |
||
337 | 2 | $policies, |
|
338 | $addAces, |
||
339 | $removeAces, |
||
340 | 2 | $extension |
|
341 | ); |
||
342 | |||
343 | 2 | $newObject = $this->getJsonConverter()->convertObject((array) $this->postJson($url, $queryArray)); |
|
344 | 2 | ||
345 | 2 | return ($newObject === null) ? null : $newObject->getId(); |
|
346 | 2 | } |
|
347 | 2 | ||
348 | 2 | /** |
|
349 | * Creates a policy object of the specified type (given by the cmis:objectTypeId property). |
||
350 | 2 | * |
|
351 | * @param string $repositoryId The identifier for the repository |
||
352 | 2 | * @param PropertiesInterface $properties The property values that must be applied to the newly |
|
353 | * created document object |
||
354 | 2 | * @param string|null $folderId If specified, the identifier for the folder that must be the parent folder for the |
|
355 | * newly created document object |
||
356 | 2 | * @param string[] $policies A list of policy IDs that must be applied to the newly created document object |
|
357 | * @param AclInterface|null $addAces A list of ACEs that must be added to the newly created document object, |
||
358 | * either using the ACL from folderId if specified, or being applied if no folderId is specified |
||
359 | * @param AclInterface|null $removeAces A list of ACEs that must be removed from the newly created document object, |
||
360 | * either using the ACL from folderId if specified, or being ignored if no folderId is specified |
||
361 | * @param ExtensionDataInterface|null $extension |
||
362 | * @return string The id of the newly-created policy. |
||
363 | */ |
||
364 | public function createPolicy( |
||
365 | $repositoryId, |
||
366 | PropertiesInterface $properties, |
||
367 | $folderId = null, |
||
368 | array $policies = [], |
||
369 | AclInterface $addAces = null, |
||
370 | AclInterface $removeAces = null, |
||
371 | ExtensionDataInterface $extension = null |
||
372 | ) { |
||
373 | // TODO: Implement createPolicy() method. |
||
374 | } |
||
375 | |||
376 | /** |
||
377 | * Creates a relationship object of the specified type (given by the cmis:objectTypeId property). |
||
378 | * |
||
379 | * @param string $repositoryId the identifier for the repository |
||
380 | * @param PropertiesInterface $properties the property values that must be applied to the newly |
||
381 | * created document object |
||
382 | * @param string[] $policies a list of policy IDs that must be applied to the newly created document object |
||
383 | * @param AclInterface|null $addAces a list of ACEs that must be added to the newly created document object, |
||
384 | * either using the ACL from folderId if specified, or being applied if no folderId is specified |
||
385 | * @param AclInterface|null $removeAces a list of ACEs that must be removed from the newly created document object, |
||
386 | * either using the ACL from folderId if specified, or being ignored if no folderId is specified |
||
387 | * @param ExtensionDataInterface|null $extension |
||
388 | * @return string|null Returns the new item id of the relationship object or <code>null</code> if the repository |
||
389 | * sent an empty result (which should not happen) |
||
390 | */ |
||
391 | View Code Duplication | public function createRelationship( |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
392 | $repositoryId, |
||
393 | PropertiesInterface $properties, |
||
394 | array $policies = [], |
||
395 | AclInterface $addAces = null, |
||
396 | AclInterface $removeAces = null, |
||
397 | ExtensionDataInterface $extension = null |
||
398 | ) { |
||
399 | $url = $this->getRepositoryUrl($repositoryId); |
||
400 | |||
401 | $queryArray = $this->createQueryArray( |
||
402 | Constants::CMISACTION_CREATE_RELATIONSHIP, |
||
403 | $properties, |
||
404 | $policies, |
||
405 | $addAces, |
||
406 | $removeAces, |
||
407 | $extension |
||
408 | ); |
||
409 | |||
410 | $newObject = $this->getJsonConverter()->convertObject((array) $this->postJson($url, $queryArray)); |
||
411 | |||
412 | return ($newObject === null) ? null : $newObject->getId(); |
||
413 | } |
||
414 | |||
415 | /** |
||
416 | * Deletes the content stream for the specified document object. |
||
417 | * |
||
418 | * @param string $repositoryId the identifier for the repository |
||
419 | * @param string $objectId the identifier for the object. The repository might return a different/new object id |
||
420 | * @param string|null $changeToken the last change token of this object that the client received. |
||
421 | * The repository might return a new change token (default is <code>null</code>) |
||
422 | * @param ExtensionDataInterface|null $extension |
||
423 | * @throws CmisInvalidArgumentException If $objectId is empty |
||
424 | */ |
||
425 | public function deleteContentStream( |
||
426 | $repositoryId, |
||
427 | & $objectId, |
||
428 | & $changeToken = null, |
||
429 | ExtensionDataInterface $extension = null |
||
430 | ) { |
||
431 | if (empty($objectId)) { |
||
432 | throw new CmisInvalidArgumentException('Object id must not be empty!'); |
||
433 | } |
||
434 | |||
435 | $this->flushCached(); |
||
436 | |||
437 | $url = $this->getObjectUrl($repositoryId, $objectId); |
||
438 | 3 | ||
439 | $url->getQuery()->modify( |
||
440 | [ |
||
441 | Constants::CONTROL_CMISACTION => Constants::CMISACTION_DELETE_CONTENT, |
||
442 | Constants::PARAM_SUCCINCT => $this->getSuccinct() ? 'true' : 'false' |
||
443 | ] |
||
444 | 3 | ); |
|
445 | |||
446 | View Code Duplication | if ($changeToken !== null && !$this->getSession()->get(SessionParameter::OMIT_CHANGE_TOKENS, false)) { |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
447 | $url->getQuery()->modify([Constants::PARAM_CHANGE_TOKEN => $changeToken]); |
||
448 | 3 | } |
|
449 | |||
450 | 3 | $newObject = $this->getJsonConverter()->convertObject((array) $this->postJson($url)); |
|
451 | |||
452 | 3 | // $objectId was passed by reference. The value is changed here to new object id |
|
453 | $objectId = null; |
||
454 | 3 | View Code Duplication | if ($newObject !== null) { |
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
455 | 3 | $objectId = $newObject->getId(); |
|
456 | 3 | $newObjectProperties = $newObject->getProperties()->getProperties(); |
|
457 | 3 | if ($changeToken !== null && count($newObjectProperties) > 0) { |
|
458 | $newChangeToken = $newObjectProperties[PropertyIds::CHANGE_TOKEN]; |
||
459 | 3 | // $changeToken was passed by reference. The value is changed here |
|
460 | 1 | $changeToken = $newChangeToken === null ? null : $newChangeToken->getFirstValue(); |
|
461 | 1 | } |
|
462 | } |
||
463 | 3 | } |
|
464 | 3 | ||
465 | /** |
||
466 | * Deletes the specified object. |
||
467 | 3 | * |
|
468 | 3 | * @param string $repositoryId the identifier for the repository |
|
469 | 3 | * @param string $objectId the identifier for the object |
|
470 | 3 | * @param boolean $allVersions If <code>true</code> then delete all versions of the document, otherwise delete only |
|
471 | 3 | * the document object specified (default is <code>true</code>) |
|
472 | 2 | * @param ExtensionDataInterface|null $extension |
|
473 | */ |
||
474 | 2 | View Code Duplication | public function deleteObject( |
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
475 | 2 | $repositoryId, |
|
476 | 3 | $objectId, |
|
477 | 3 | $allVersions = true, |
|
478 | ExtensionDataInterface $extension = null |
||
479 | ) { |
||
480 | $url = $this->getObjectUrl($repositoryId, $objectId); |
||
481 | $content = [ |
||
482 | Constants::CONTROL_CMISACTION => Constants::CMISACTION_DELETE, |
||
483 | Constants::PARAM_ALL_VERSIONS => $allVersions ? 'true' : 'false', |
||
484 | ]; |
||
485 | |||
486 | $this->post($url, $content); |
||
487 | $this->flushCached(); |
||
488 | 2 | } |
|
489 | |||
490 | /** |
||
491 | * Deletes the specified folder object and all of its child- and descendant-objects. |
||
492 | * |
||
493 | * @param string $repositoryId the identifier for the repository |
||
494 | 2 | * @param string $folderId the identifier for the folder |
|
495 | 2 | * @param boolean $allVersions If <code>true</code> then delete all versions of the document, otherwise delete only |
|
496 | * the document object specified (default is <code>true</code>) |
||
497 | 2 | * @param UnfileObject|null $unfileObjects defines how the repository must process file-able child- or |
|
498 | 2 | * descendant-objects (default is <code>UnfileObject::DELETE</code>) |
|
499 | * @param boolean $continueOnFailure If <code>true</code>, then the repository should continue attempting to |
||
500 | 2 | * perform this operation even if deletion of a child- or descendant-object in the specified folder cannot |
|
501 | * be deleted |
||
502 | 2 | * @param ExtensionDataInterface|null $extension |
|
503 | 2 | * @return FailedToDeleteDataInterface Returns a list of object ids that could not be deleted |
|
504 | 2 | */ |
|
505 | public function deleteTree( |
||
506 | $repositoryId, |
||
507 | $folderId, |
||
508 | $allVersions = true, |
||
509 | UnfileObject $unfileObjects = null, |
||
510 | $continueOnFailure = false, |
||
511 | ExtensionDataInterface $extension = null |
||
512 | ) { |
||
513 | $url = $this->getObjectUrl($repositoryId, $folderId); |
||
514 | $url->getQuery()->modify( |
||
515 | [ |
||
516 | Constants::CONTROL_CMISACTION => Constants::CMISACTION_DELETE_TREE, |
||
517 | Constants::PARAM_FOLDER_ID => $folderId, |
||
518 | Constants::PARAM_ALL_VERSIONS => $allVersions ? 'true' : 'false', |
||
519 | Constants::PARAM_CONTINUE_ON_FAILURE => $continueOnFailure ? 'true' : 'false' |
||
520 | ] |
||
521 | 4 | ); |
|
522 | |||
523 | if ($unfileObjects !== null) { |
||
524 | $url->getQuery()->modify([Constants::PARAM_UNFILE_OBJECTS => (string) $unfileObjects]); |
||
525 | } |
||
526 | |||
527 | return $this->getJsonConverter()->convertFailedToDelete($this->postJson($url)); |
||
528 | } |
||
529 | 4 | ||
530 | 4 | /** |
|
531 | * Gets the list of allowable actions for an object. |
||
532 | 4 | * |
|
533 | 4 | * @param string $repositoryId the identifier for the repository |
|
534 | 4 | * @param string $objectId the identifier for the object |
|
535 | 4 | * @param ExtensionDataInterface|null $extension |
|
536 | 4 | * @return AllowableActionsInterface |
|
537 | 4 | */ |
|
538 | public function getAllowableActions($repositoryId, $objectId, ExtensionDataInterface $extension = null) |
||
539 | 4 | { |
|
540 | 1 | // TODO: Implement getAllowableActions() method. |
|
541 | 1 | } |
|
542 | |||
543 | 4 | /** |
|
544 | * Gets the content stream for the specified document object, or gets a rendition stream for |
||
545 | 4 | * a specified rendition of a document or folder object. |
|
546 | 4 | * |
|
547 | 4 | * @param string $repositoryId the identifier for the repository |
|
548 | * @param string $objectId the identifier for the object |
||
549 | 4 | * @param string|null $streamId The identifier for the rendition stream, when used to get a rendition stream. |
|
550 | 4 | * For documents, if not provided then this method returns the content stream. For folders, |
|
551 | * it MUST be provided. |
||
552 | * @param integer|null $offset |
||
553 | * @param integer|null $length |
||
554 | * @param ExtensionDataInterface|null $extension |
||
555 | * @return StreamInterface|null |
||
556 | * @throws CmisInvalidArgumentException If object id is empty |
||
557 | */ |
||
558 | public function getContentStream( |
||
559 | $repositoryId, |
||
560 | $objectId, |
||
561 | $streamId = null, |
||
562 | $offset = null, |
||
563 | $length = null, |
||
564 | ExtensionDataInterface $extension = null |
||
565 | ) { |
||
566 | if (empty($objectId)) { |
||
567 | throw new CmisInvalidArgumentException('Object id must not be empty!'); |
||
568 | } |
||
569 | |||
570 | $url = $this->getObjectUrl($repositoryId, $objectId, Constants::SELECTOR_CONTENT); |
||
571 | |||
572 | if ($streamId !== null) { |
||
573 | $url->getQuery()->modify([Constants::PARAM_STREAM_ID => $streamId]); |
||
574 | } |
||
575 | |||
576 | /** @var Response $response */ |
||
577 | $response = $this->getHttpInvoker()->get((string) $url); |
||
578 | |||
579 | $contentStream = $response->getBody(); |
||
580 | if (!$contentStream) { |
||
581 | 3 | return null; |
|
582 | } |
||
583 | |||
584 | if ($offset !== null) { |
||
585 | $contentStream = new LimitStream($contentStream, $length !== null ? $length : - 1, $offset); |
||
586 | } |
||
587 | |||
588 | return $contentStream; |
||
589 | 3 | } |
|
590 | |||
591 | /** |
||
592 | * Gets the specified information for the object specified by id. |
||
593 | 3 | * |
|
594 | * @param string $repositoryId the identifier for the repository |
||
595 | 3 | * @param string $objectId the identifier for the object |
|
596 | 1 | * @param string|null $filter a comma-separated list of query names that defines which properties must be |
|
597 | 1 | * returned by the repository (default is repository specific) |
|
598 | * @param boolean $includeAllowableActions if <code>true</code>, then the repository must return the allowable |
||
599 | * actions for the object (default is <code>false</code>) |
||
600 | 3 | * @param IncludeRelationships|null $includeRelationships indicates what relationships in which the objects |
|
601 | * participate must be returned (default is <code>IncludeRelationships::NONE</code>) |
||
602 | 3 | * @param string $renditionFilter indicates what set of renditions the repository must return whose kind |
|
603 | 3 | * matches this filter (default is "cmis:none") |
|
604 | * @param boolean $includePolicyIds if <code>true</code>, then the repository must return the policy ids for |
||
605 | * the object (default is <code>false</code>) |
||
606 | * @param boolean $includeAcl if <code>true</code>, then the repository must return the ACL for the object |
||
607 | 3 | * (default is <code>false</code>) |
|
608 | 1 | * @param ExtensionDataInterface|null $extension |
|
609 | 1 | * @return ObjectDataInterface|null Returns object of type ObjectDataInterface or <code>null</code> |
|
610 | * if the repository response was empty |
||
611 | 3 | */ |
|
612 | View Code Duplication | public function getObject( |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
613 | $repositoryId, |
||
614 | $objectId, |
||
615 | $filter = null, |
||
616 | $includeAllowableActions = false, |
||
617 | IncludeRelationships $includeRelationships = null, |
||
618 | $renditionFilter = Constants::RENDITION_NONE, |
||
619 | $includePolicyIds = false, |
||
620 | $includeAcl = false, |
||
621 | ExtensionDataInterface $extension = null |
||
622 | ) { |
||
623 | $cacheKey = $this->createCacheKey( |
||
624 | $objectId, |
||
625 | [ |
||
626 | $repositoryId, |
||
627 | $filter, |
||
628 | $includeAllowableActions, |
||
629 | $includeRelationships, |
||
630 | $renditionFilter, |
||
631 | $includePolicyIds, |
||
632 | $includeAcl, |
||
633 | $extension, |
||
634 | $this->getSuccinct() |
||
635 | 3 | ] |
|
636 | ); |
||
637 | if ($this->isCached($cacheKey)) { |
||
638 | return $this->getCached($cacheKey); |
||
639 | } |
||
640 | $url = $this->getObjectUrl($repositoryId, $objectId, Constants::SELECTOR_OBJECT); |
||
641 | $url->getQuery()->modify( |
||
642 | [ |
||
643 | Constants::PARAM_ALLOWABLE_ACTIONS => $includeAllowableActions ? 'true' : 'false', |
||
644 | Constants::PARAM_RENDITION_FILTER => $renditionFilter, |
||
645 | Constants::PARAM_POLICY_IDS => $includePolicyIds ? 'true' : 'false', |
||
646 | 3 | Constants::PARAM_ACL => $includeAcl ? 'true' : 'false', |
|
647 | 3 | Constants::PARAM_SUCCINCT => $this->getSuccinct() ? 'true' : 'false', |
|
648 | Constants::PARAM_DATETIME_FORMAT => (string) $this->getDateTimeFormat() |
||
649 | 3 | ] |
|
650 | 3 | ); |
|
651 | 3 | ||
652 | 3 | if (!empty($filter)) { |
|
653 | 3 | $url->getQuery()->modify([Constants::PARAM_FILTER => (string) $filter]); |
|
654 | 3 | } |
|
655 | 3 | ||
656 | 3 | if ($includeRelationships !== null) { |
|
657 | 3 | $url->getQuery()->modify([Constants::PARAM_RELATIONSHIPS => (string) $includeRelationships]); |
|
658 | 3 | } |
|
659 | 3 | ||
660 | 3 | $responseData = (array) $this->readJson($url); |
|
661 | |||
662 | return $this->cache( |
||
663 | 3 | $cacheKey, |
|
664 | 3 | $this->getJsonConverter()->convertObject($responseData) |
|
665 | ); |
||
666 | 3 | } |
|
667 | 3 | ||
668 | 3 | /** |
|
669 | 3 | * Gets the specified information for the object specified by path. |
|
670 | 3 | * |
|
671 | 3 | * @param string $repositoryId the identifier for the repository |
|
672 | 3 | * @param string $path the path to the object |
|
673 | 3 | * @param string|null $filter a comma-separated list of query names that defines which properties must be |
|
674 | * returned by the repository (default is repository specific) |
||
675 | 3 | * @param boolean $includeAllowableActions if <code>true</code>, then the repository must return the allowable |
|
676 | 2 | * actions for the object (default is <code>false</code>) |
|
677 | 2 | * @param IncludeRelationships|null $includeRelationships indicates what relationships in which the objects |
|
678 | * participate must be returned (default is <code>IncludeRelationships::NONE</code>) |
||
679 | 3 | * @param string $renditionFilter indicates what set of renditions the repository must return whose kind |
|
680 | 2 | * matches this filter (default is "cmis:none") |
|
681 | 2 | * @param boolean $includePolicyIds if <code>true</code>, then the repository must return the policy ids for |
|
682 | * the object (default is <code>false</code>) |
||
683 | 3 | * @param boolean $includeAcl if <code>true</code>, then the repository must return the ACL for the object |
|
684 | * (default is <code>false</code>) |
||
685 | 3 | * @param ExtensionDataInterface|null $extension |
|
686 | 3 | * @return ObjectDataInterface|null Returns object of type <code>ObjectDataInterface</code> or <code>null</code> |
|
687 | 3 | * if the repository response was empty |
|
688 | 3 | */ |
|
689 | View Code Duplication | public function getObjectByPath( |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
690 | $repositoryId, |
||
691 | $path, |
||
692 | $filter = null, |
||
693 | $includeAllowableActions = false, |
||
694 | IncludeRelationships $includeRelationships = null, |
||
695 | $renditionFilter = Constants::RENDITION_NONE, |
||
696 | $includePolicyIds = false, |
||
697 | $includeAcl = false, |
||
698 | ExtensionDataInterface $extension = null |
||
699 | ) { |
||
700 | $cacheKey = $this->createCacheKey( |
||
701 | $path, |
||
702 | [ |
||
703 | $repositoryId, |
||
704 | $filter, |
||
705 | $includeAllowableActions, |
||
706 | $includeRelationships, |
||
707 | $renditionFilter, |
||
708 | $includePolicyIds, |
||
709 | $includeAcl, |
||
710 | $extension, |
||
711 | $this->getSuccinct() |
||
712 | 3 | ] |
|
713 | ); |
||
714 | if ($this->isCached($cacheKey)) { |
||
715 | return $this->getCached($cacheKey); |
||
716 | } |
||
717 | |||
718 | $url = $this->getPathUrl($repositoryId, $path, Constants::SELECTOR_OBJECT); |
||
719 | $url->getQuery()->modify( |
||
720 | [ |
||
721 | Constants::PARAM_ALLOWABLE_ACTIONS => $includeAllowableActions ? 'true' : 'false', |
||
722 | Constants::PARAM_RENDITION_FILTER => $renditionFilter, |
||
723 | 3 | Constants::PARAM_POLICY_IDS => $includePolicyIds ? 'true' : 'false', |
|
724 | 3 | Constants::PARAM_ACL => $includeAcl ? 'true' : 'false', |
|
725 | Constants::PARAM_SUCCINCT => $this->getSuccinct() ? 'true' : 'false', |
||
726 | 3 | Constants::PARAM_DATETIME_FORMAT => (string) $this->getDateTimeFormat() |
|
727 | 3 | ] |
|
728 | 3 | ); |
|
729 | 3 | ||
730 | 3 | if (!empty($filter)) { |
|
731 | 3 | $url->getQuery()->modify([Constants::PARAM_FILTER => (string) $filter]); |
|
732 | 3 | } |
|
733 | 3 | ||
734 | 3 | if ($includeRelationships !== null) { |
|
735 | 3 | $url->getQuery()->modify([Constants::PARAM_RELATIONSHIPS => (string) $includeRelationships]); |
|
736 | 3 | } |
|
737 | 3 | ||
738 | $responseData = (array) $this->readJson($url); |
||
739 | |||
740 | return $this->cache( |
||
741 | 3 | $cacheKey, |
|
742 | 3 | $this->getJsonConverter()->convertObject($responseData) |
|
743 | ); |
||
744 | 3 | } |
|
745 | 3 | ||
746 | 3 | /** |
|
747 | 3 | * Gets the list of properties for an object. |
|
748 | 3 | * |
|
749 | 3 | * @param string $repositoryId the identifier for the repository |
|
750 | 3 | * @param string $objectId the identifier for the object |
|
751 | 3 | * @param string|null $filter a comma-separated list of query names that defines which properties must be |
|
752 | * returned by the repository (default is repository specific) |
||
753 | 3 | * @param ExtensionDataInterface|null $extension |
|
754 | 2 | * @return PropertiesInterface |
|
755 | 2 | */ |
|
756 | public function getProperties( |
||
757 | 3 | $repositoryId, |
|
758 | 2 | $objectId, |
|
759 | 2 | $filter = null, |
|
760 | ExtensionDataInterface $extension = null |
||
761 | 3 | ) { |
|
762 | $cacheKey = $this->createCacheKey( |
||
763 | 3 | $objectId, |
|
764 | 3 | [ |
|
765 | 3 | $repositoryId, |
|
766 | 3 | $filter, |
|
767 | $extension, |
||
768 | $this->getSuccinct() |
||
769 | ] |
||
770 | ); |
||
771 | |||
772 | if ($this->isCached($cacheKey)) { |
||
773 | return $this->getCached($cacheKey); |
||
774 | } |
||
775 | |||
776 | $url = $this->getObjectUrl($repositoryId, $objectId, Constants::SELECTOR_PROPERTIES); |
||
777 | $url->getQuery()->modify( |
||
778 | [ |
||
779 | 2 | Constants::PARAM_SUCCINCT => $this->getSuccinct() ? 'true' : 'false', |
|
780 | Constants::PARAM_DATETIME_FORMAT => (string) $this->getDateTimeFormat() |
||
781 | ] |
||
782 | ); |
||
783 | |||
784 | if (!empty($filter)) { |
||
785 | 2 | $url->getQuery()->modify([Constants::PARAM_FILTER => (string) $filter]); |
|
786 | 2 | } |
|
787 | |||
788 | 2 | $responseData = (array) $this->readJson($url); |
|
789 | 2 | ||
790 | 2 | if ($this->getSuccinct()) { |
|
791 | 2 | $objectData = $this->getJsonConverter()->convertSuccinctProperties($responseData); |
|
792 | 2 | } else { |
|
793 | 2 | $objectData = $this->getJsonConverter()->convertProperties($responseData); |
|
794 | } |
||
795 | 2 | ||
796 | return $this->cache( |
||
797 | $cacheKey, |
||
798 | $objectData |
||
799 | 2 | ); |
|
800 | 2 | } |
|
801 | |||
802 | 2 | /** |
|
803 | 2 | * Gets the list of associated renditions for the specified object. |
|
804 | 2 | * Only rendition attributes are returned, not rendition stream. |
|
805 | 2 | * |
|
806 | * @param string $repositoryId the identifier for the repository |
||
807 | 2 | * @param string $objectId the identifier for the object |
|
808 | 1 | * @param string $renditionFilter indicates what set of renditions the repository must return whose kind |
|
809 | 1 | * matches this filter (default is "cmis:none") |
|
810 | * @param integer|null $maxItems the maximum number of items to return in a response |
||
811 | 2 | * (default is repository specific) |
|
812 | * @param integer $skipCount number of potential results that the repository MUST skip/page over before |
||
813 | 2 | * returning any results (default is 0) |
|
814 | * @param ExtensionDataInterface|null $extension |
||
815 | * @return RenditionDataInterface[] |
||
816 | 2 | * @throws CmisInvalidArgumentException If object id is empty or skip count not of type integer |
|
817 | */ |
||
818 | public function getRenditions( |
||
819 | 2 | $repositoryId, |
|
820 | 2 | $objectId, |
|
821 | $renditionFilter = Constants::RENDITION_NONE, |
||
822 | 2 | $maxItems = null, |
|
823 | $skipCount = 0, |
||
824 | ExtensionDataInterface $extension = null |
||
825 | ) { |
||
826 | if (empty($objectId)) { |
||
827 | throw new CmisInvalidArgumentException('Object id must not be empty!'); |
||
828 | } |
||
829 | |||
830 | if (!is_int($skipCount)) { |
||
831 | throw new CmisInvalidArgumentException('Skip count must be of type integer!'); |
||
832 | } |
||
833 | |||
834 | $url = $this->getObjectUrl($repositoryId, $objectId, Constants::SELECTOR_RENDITIONS); |
||
835 | $url->getQuery()->modify( |
||
836 | [ |
||
837 | Constants::PARAM_RENDITION_FILTER => $renditionFilter, |
||
838 | Constants::PARAM_SKIP_COUNT => (string) $skipCount, |
||
839 | ] |
||
840 | ); |
||
841 | 2 | ||
842 | if ($maxItems !== null) { |
||
843 | $url->getQuery()->modify([Constants::PARAM_MAX_ITEMS => (string) $maxItems]); |
||
844 | } |
||
845 | |||
846 | $responseData = (array) $this->readJson($url); |
||
847 | |||
848 | return $this->getJsonConverter()->convertRenditions($responseData); |
||
849 | 2 | } |
|
850 | |||
851 | /** |
||
852 | * Moves the specified file-able object from one folder to another. |
||
853 | 2 | * |
|
854 | * @param string $repositoryId the identifier for the repository |
||
855 | * @param string $objectId the identifier for the object. The repository might return a different/new object id |
||
856 | * @param string $targetFolderId the identifier for the target folder |
||
857 | 2 | * @param string $sourceFolderId the identifier for the source folder |
|
858 | 2 | * @param ExtensionDataInterface|null $extension |
|
859 | * @return ObjectDataInterface|null Returns object of type ObjectDataInterface or <code>null</code> |
||
860 | 2 | * if the repository response was empty |
|
861 | 2 | */ |
|
862 | public function moveObject( |
||
863 | 2 | $repositoryId, |
|
864 | & $objectId, |
||
865 | 2 | $targetFolderId, |
|
866 | 1 | $sourceFolderId, |
|
867 | 1 | ExtensionDataInterface $extension = null |
|
868 | ) { |
||
869 | 2 | $this->flushCached(); |
|
870 | |||
871 | 2 | $url = $this->getObjectUrl($repositoryId, $objectId); |
|
872 | $url->getQuery()->modify( |
||
873 | [ |
||
874 | Constants::CONTROL_CMISACTION => Constants::CMISACTION_MOVE, |
||
875 | Constants::PARAM_TARGET_FOLDER_ID => $targetFolderId, |
||
876 | Constants::PARAM_SOURCE_FOLDER_ID => $sourceFolderId, |
||
877 | Constants::PARAM_SUCCINCT => $this->getSuccinct() ? 'true' : 'false' |
||
878 | ] |
||
879 | ); |
||
880 | |||
881 | $newObject = $this->getJsonConverter()->convertObject($this->postJson($url)); |
||
882 | |||
883 | // $objectId was passed by reference. The value is changed here to new object id |
||
884 | $objectId = ($newObject === null) ? null : $newObject->getId(); |
||
885 | 1 | ||
886 | return $newObject; |
||
887 | } |
||
888 | |||
889 | /** |
||
890 | * Sets the content stream for the specified document object. |
||
891 | * |
||
892 | 1 | * @param string $repositoryId The identifier for the repository |
|
893 | * @param string $objectId The identifier for the object. The repository might return a different/new object id |
||
894 | 1 | * @param StreamInterface $contentStream The content stream |
|
895 | 1 | * @param boolean $overwriteFlag If <code>true</code>, then the repository must replace the existing content stream |
|
896 | * for the object (if any) with the input content stream. If <code>false</code>, then the repository must |
||
897 | 1 | * only set the input content stream for the object if the object currently does not have a content stream |
|
898 | 1 | * (default is <code>true</code>) |
|
899 | 1 | * @param string|null $changeToken The last change token of this object that the client received. |
|
900 | 1 | * The repository might return a new change token (default is <code>null</code>) |
|
901 | 1 | * @param ExtensionDataInterface|null $extension |
|
902 | 1 | * @throws CmisInvalidArgumentException If object id is empty |
|
903 | */ |
||
904 | 1 | public function setContentStream( |
|
905 | 1 | $repositoryId, |
|
906 | & $objectId, |
||
907 | StreamInterface $contentStream, |
||
908 | 1 | $overwriteFlag = true, |
|
909 | & $changeToken = null, |
||
910 | 1 | ExtensionDataInterface $extension = null |
|
911 | ) { |
||
912 | if (empty($objectId)) { |
||
913 | throw new CmisInvalidArgumentException('Object id must not be empty!'); |
||
914 | } |
||
915 | |||
916 | $this->flushCached(); |
||
917 | |||
918 | $url = $this->getObjectUrl($repositoryId, $objectId); |
||
919 | |||
920 | $url->getQuery()->modify( |
||
921 | [ |
||
922 | Constants::CONTROL_CMISACTION => Constants::CMISACTION_SET_CONTENT, |
||
923 | Constants::PARAM_OVERWRITE_FLAG => $overwriteFlag ? 'true' : 'false', |
||
924 | Constants::PARAM_SUCCINCT => $this->getSuccinct() ? 'true' : 'false' |
||
925 | ] |
||
926 | ); |
||
927 | |||
928 | 3 | View Code Duplication | if ($changeToken !== null && !$this->getSession()->get(SessionParameter::OMIT_CHANGE_TOKENS, false)) { |
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
929 | $url->getQuery()->modify([Constants::PARAM_CHANGE_TOKEN => $changeToken]); |
||
930 | } |
||
931 | |||
932 | $newObject = $this->getJsonConverter()->convertObject( |
||
933 | (array) $this->postJson($url, ['content' => $contentStream]) |
||
934 | ); |
||
935 | |||
936 | 3 | // $objectId was passed by reference. The value is changed here to new object id |
|
937 | $objectId = null; |
||
938 | View Code Duplication | if ($newObject !== null) { |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
939 | $objectId = $newObject->getId(); |
||
940 | 3 | $newObjectProperties = $newObject->getProperties()->getProperties(); |
|
941 | if ($changeToken !== null && count($newObjectProperties) > 0) { |
||
942 | 3 | $newChangeToken = $newObjectProperties[PropertyIds::CHANGE_TOKEN]; |
|
943 | // $changeToken was passed by reference. The value is changed here |
||
944 | 3 | $changeToken = $newChangeToken === null ? null : $newChangeToken->getFirstValue(); |
|
945 | } |
||
946 | 3 | } |
|
947 | 3 | } |
|
948 | 3 | ||
949 | 3 | /** |
|
950 | 3 | * Updates properties of the specified object. |
|
951 | * |
||
952 | 3 | * @param string $repositoryId The identifier for the repository |
|
953 | 1 | * @param string $objectId The identifier for the object. The repository might return a different/new object id |
|
954 | 1 | * @param PropertiesInterface $properties The updated property values that must be applied to the object |
|
955 | * @param string|null $changeToken The last change token of this object that the client received. |
||
956 | 3 | * The repository might return a new change token (default is <code>null</code>) |
|
957 | 3 | * @param ExtensionDataInterface|null $extension |
|
958 | * @throws CmisInvalidArgumentException If $objectId is empty |
||
959 | 3 | */ |
|
960 | public function updateProperties( |
||
961 | 3 | $repositoryId, |
|
962 | & $objectId, |
||
963 | PropertiesInterface $properties, |
||
964 | 3 | & $changeToken = null, |
|
965 | 3 | ExtensionDataInterface $extension = null |
|
966 | 3 | ) { |
|
967 | 3 | if (empty($objectId)) { |
|
968 | 3 | throw new CmisInvalidArgumentException('Object id must not be empty!'); |
|
969 | 2 | } |
|
970 | |||
971 | 2 | $this->flushCached(); |
|
972 | 2 | ||
973 | 3 | $url = $this->getObjectUrl($repositoryId, $objectId); |
|
974 | 3 | ||
975 | View Code Duplication | if ($changeToken !== null && !$this->getSession()->get(SessionParameter::OMIT_CHANGE_TOKENS, false)) { |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
976 | $url->getQuery()->modify([Constants::PARAM_CHANGE_TOKEN => $changeToken]); |
||
977 | } |
||
978 | |||
979 | $queryArray = $this->convertPropertiesToQueryArray($properties); |
||
980 | $queryArray[Constants::CONTROL_CMISACTION] = Constants::CMISACTION_UPDATE_PROPERTIES; |
||
981 | $queryArray[Constants::PARAM_SUCCINCT] = $this->getSuccinct() ? 'true' : 'false'; |
||
982 | $newObject = $this->getJsonConverter()->convertObject((array) $this->postJson($url, $queryArray)); |
||
983 | |||
984 | // $objectId was passed by reference. The value is changed here to new object id |
||
985 | $objectId = null; |
||
986 | View Code Duplication | if ($newObject !== null) { |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
987 | 3 | $objectId = $newObject->getId(); |
|
988 | $newObjectProperties = $newObject->getProperties()->getProperties(); |
||
989 | if ($changeToken !== null && count($newObjectProperties) > 0) { |
||
990 | $newChangeToken = $newObjectProperties[PropertyIds::CHANGE_TOKEN]; |
||
991 | // $changeToken was passed by reference. The value is changed here |
||
992 | $changeToken = $newChangeToken === null ? null : $newChangeToken->getFirstValue(); |
||
993 | } |
||
994 | 3 | } |
|
995 | } |
||
996 | |||
997 | /** |
||
998 | 3 | * @param string $identifier |
|
999 | * @param mixed $additionalHashValues |
||
1000 | 3 | * @return array |
|
1001 | */ |
||
1002 | 3 | protected function createCacheKey($identifier, $additionalHashValues) |
|
1003 | 1 | { |
|
1004 | 1 | return [ |
|
1005 | $identifier, |
||
1006 | 3 | sha1(is_array($additionalHashValues) ? serialize($additionalHashValues) : $additionalHashValues) |
|
1007 | 3 | ]; |
|
1008 | 3 | } |
|
1009 | 3 | ||
1010 | 3 | /** |
|
1011 | * Returns TRUE if an object with cache key $identifier is currently cached. |
||
1012 | * |
||
1013 | 3 | * @param array $identifier |
|
1014 | 3 | * @return boolean |
|
1015 | 3 | */ |
|
1016 | 3 | protected function isCached(array $identifier) |
|
1017 | 3 | { |
|
1018 | 2 | return isset($this->objectCache[$identifier[0]][$identifier[1]]); |
|
1019 | } |
||
1020 | 2 | ||
1021 | 2 | /** |
|
1022 | 3 | * Gets the cached object with cache key $identifier. |
|
1023 | 3 | * |
|
1024 | * @param string $identifier |
||
0 ignored issues
–
show
Should the type for parameter
$identifier not be array ? Also, consider making the array more specific, something like array<String> , or String[] .
This check looks for It makes a suggestion as to what type it considers more descriptive. In addition it
looks for parameters that have the generic type Most often this is a case of a parameter that can be null in addition to its declared types. ![]() |
|||
1025 | * @return mixed |
||
1026 | */ |
||
1027 | protected function getCached(array $identifier) |
||
1028 | { |
||
1029 | return $this->objectCache[$identifier[0]][$identifier[1]] ?? null; |
||
1030 | 8 | } |
|
1031 | |||
1032 | /** |
||
1033 | 8 | * Gets the cached object with cache key $identifier. |
|
1034 | 8 | * |
|
1035 | 8 | * @param string $identifier |
|
0 ignored issues
–
show
Should the type for parameter
$identifier not be array ? Also, consider making the array more specific, something like array<String> , or String[] .
This check looks for It makes a suggestion as to what type it considers more descriptive. In addition it
looks for parameters that have the generic type Most often this is a case of a parameter that can be null in addition to its declared types. ![]() |
|||
1036 | * @param mixed $object |
||
1037 | * @return mixed |
||
1038 | */ |
||
1039 | protected function cache(array $identifier, $object) |
||
1040 | { |
||
1041 | $this->objectCache[$identifier[0]][$identifier[1]] = $object; |
||
1042 | return $object; |
||
1043 | } |
||
1044 | 8 | ||
1045 | /** |
||
1046 | 8 | * Flushes all cached entries. This is implemented as a flush-all with |
|
1047 | * no way to flush individual entries due to the way CMIS object data |
||
1048 | * gets returned from CMIS. Two widely different object data sets may |
||
1049 | * contain a reference to the same item and even with extensive cross |
||
1050 | * referencing it would be technically unfeasible to selectively clear |
||
1051 | * or reload an object by identifier. Such flushing would be inevitably |
||
1052 | * flawed with edge cases of incomplete flushing or become so complex |
||
1053 | * that it defeats the purpose of caching in the first place. |
||
1054 | * |
||
1055 | * Note that cache flushing only happens when modifying the repository |
||
1056 | * contents - which should limit the negative impact. The cache is also |
||
1057 | * not persistent and will only affect the current request. As such, it |
||
1058 | * is implemented to optimise requests where the same object, type, |
||
1059 | * policy etc. gets accessed multiple times. |
||
1060 | * |
||
1061 | * @return void |
||
1062 | */ |
||
1063 | protected function flushCached() |
||
1064 | { |
||
1065 | $this->objectCache = []; |
||
1066 | } |
||
1067 | } |
||
1068 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.