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