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