1
|
|
|
<?php |
2
|
|
|
namespace Dkd\PhpCmis\DataObjects; |
3
|
|
|
|
4
|
|
|
/* |
5
|
|
|
* This file is part of php-cmis-client. |
6
|
|
|
* |
7
|
|
|
* (c) Sascha Egerer <[email protected]> |
8
|
|
|
* |
9
|
|
|
* For the full copyright and license information, please view the LICENSE |
10
|
|
|
* file that was distributed with this source code. |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
use Dkd\PhpCmis\Bindings\LinkAccessInterface; |
14
|
|
|
use Dkd\PhpCmis\Constants; |
15
|
|
|
use Dkd\PhpCmis\Data\AceInterface; |
16
|
|
|
use Dkd\PhpCmis\Data\ContentStreamHashInterface; |
17
|
|
|
use Dkd\PhpCmis\Data\DocumentInterface; |
18
|
|
|
use Dkd\PhpCmis\Data\ObjectIdInterface; |
19
|
|
|
use Dkd\PhpCmis\Data\PolicyInterface; |
20
|
|
|
use Dkd\PhpCmis\Enum\CmisVersion; |
21
|
|
|
use Dkd\PhpCmis\Enum\IncludeRelationships; |
22
|
|
|
use Dkd\PhpCmis\Enum\Updatability; |
23
|
|
|
use Dkd\PhpCmis\Enum\VersioningState; |
24
|
|
|
use Dkd\PhpCmis\Exception\CmisNotSupportedException; |
25
|
|
|
use Dkd\PhpCmis\Exception\CmisRuntimeException; |
26
|
|
|
use Dkd\PhpCmis\Exception\CmisVersioningException; |
27
|
|
|
use Dkd\PhpCmis\OperationContextInterface; |
28
|
|
|
use Dkd\PhpCmis\PropertyIds; |
29
|
|
|
use GuzzleHttp\Stream\StreamInterface; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Cmis document implementation |
33
|
|
|
*/ |
34
|
|
|
class Document extends AbstractFileableCmisObject implements DocumentInterface |
35
|
|
|
{ |
36
|
|
|
/** |
37
|
|
|
* Appends a content stream to the content stream of the document and refreshes this object afterwards. |
38
|
|
|
* If the repository created a new version, this new document is returned. |
39
|
|
|
* Otherwise the current document is returned. |
40
|
|
|
* The stream in contentStream is consumed but not closed by this method. |
41
|
|
|
* |
42
|
|
|
* @param StreamInterface $contentStream the content stream |
43
|
|
|
* @param boolean $isLastChunk indicates if this stream is the last chunk of the content |
44
|
|
|
* @param boolean $refresh if this parameter is set to <code>true</code>, this object will be refreshed after the |
45
|
|
|
* content stream has been appended |
46
|
|
|
* @return ObjectIdInterface|null the updated object ID, or <code>null</code> if the repository did not return |
47
|
|
|
* an object ID |
48
|
|
|
* @throws CmisNotSupportedException |
49
|
|
|
*/ |
50
|
|
|
public function appendContentStream(StreamInterface $contentStream, $isLastChunk, $refresh = true) |
51
|
|
|
{ |
52
|
|
|
if ($this->getSession()->getRepositoryInfo()->getCmisVersion()->equals(CmisVersion::CMIS_1_0)) { |
53
|
|
|
throw new CmisNotSupportedException('This method is not supported for CMIS 1.0 repositories.'); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
$newObjectId = $this->getId(); |
57
|
|
|
$changeToken = $this->getPropertyValue(PropertyIds::CHANGE_TOKEN); |
58
|
|
|
|
59
|
|
|
$this->getBinding()->getObjectService()->appendContentStream( |
60
|
|
|
$this->getRepositoryId(), |
61
|
|
|
$newObjectId, |
62
|
|
|
$this->getObjectFactory()->convertContentStream($contentStream), |
63
|
|
|
$isLastChunk, |
64
|
|
|
$changeToken |
65
|
|
|
); |
66
|
|
|
|
67
|
|
|
if ($refresh) { |
68
|
|
|
$this->refresh(); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
if ($newObjectId === null) { |
72
|
|
|
return null; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
return $this->getSession()->createObjectId($newObjectId); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* If this is a PWC (private working copy) the check out will be reversed. |
80
|
|
|
*/ |
81
|
|
|
public function cancelCheckOut() |
82
|
|
|
{ |
83
|
|
|
$this->getBinding()->getVersioningService()->cancelCheckOut($this->getRepositoryId(), $this->getId()); |
|
|
|
|
84
|
|
|
|
85
|
|
|
$this->getSession()->removeObjectFromCache($this); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* If this is a PWC (private working copy) it performs a check in. |
90
|
|
|
* If this is not a PWC an exception will be thrown. |
91
|
|
|
* The stream in contentStream is consumed but not closed by this method. |
92
|
|
|
* |
93
|
|
|
* @param boolean $major <code>true</code> if the checked-in document object MUST be a major version. |
94
|
|
|
* <code>false</code> if the checked-in document object MUST NOT be a major version but a minor version. |
95
|
|
|
* @param array $properties The property values that MUST be applied to the checked-in document object. |
96
|
|
|
* @param StreamInterface $contentStream The content stream that MUST be stored for the checked-in document object. |
97
|
|
|
* The method of passing the contentStream to the server and the encoding mechanism will be specified by each |
98
|
|
|
* specific binding. MUST be required if the type requires it. |
99
|
|
|
* @param string $checkinComment Textual comment associated with the given version. MAY be "not set". |
100
|
|
|
* @param PolicyInterface[] $policies A list of policy ids that MUST be applied to the newly-created document |
101
|
|
|
* object |
102
|
|
|
* @param AceInterface[] $addAces A list of ACEs that MUST be added to the newly-created document object. |
103
|
|
|
* @param AceInterface[] $removeAces A list of ACEs that MUST be removed from the newly-created document object. |
104
|
|
|
* @return ObjectIdInterface|null The id of the checked-in document. <code>null</code> if repository has not |
105
|
|
|
* returned the new object id which could happen in case of a repository error |
106
|
|
|
*/ |
107
|
|
|
public function checkIn( |
108
|
|
|
$major, |
109
|
|
|
array $properties, |
110
|
|
|
StreamInterface $contentStream, |
111
|
|
|
$checkinComment, |
112
|
|
|
array $policies = [], |
113
|
|
|
array $addAces = [], |
114
|
|
|
array $removeAces = [] |
115
|
|
|
) { |
116
|
|
|
$newObjectId = $this->getId(); |
117
|
|
|
|
118
|
|
|
$objectFactory = $this->getObjectFactory(); |
119
|
|
|
$updatability = [ |
120
|
|
|
Updatability::cast(Updatability::READWRITE), |
121
|
|
|
Updatability::cast(Updatability::WHENCHECKEDOUT) |
122
|
|
|
]; |
123
|
|
|
|
124
|
|
|
$this->getBinding()->getVersioningService()->checkIn( |
125
|
|
|
$this->getRepositoryId(), |
126
|
|
|
$newObjectId, |
127
|
|
|
$major, |
128
|
|
|
$objectFactory->convertProperties( |
129
|
|
|
$properties, |
130
|
|
|
$this->getObjectType(), |
131
|
|
|
(array) $this->getSecondaryTypes(), |
132
|
|
|
$updatability |
133
|
|
|
), |
134
|
|
|
$objectFactory->convertContentStream($contentStream), |
135
|
|
|
$checkinComment, |
136
|
|
|
$objectFactory->convertPolicies($policies), |
137
|
|
|
$objectFactory->convertAces($addAces), |
138
|
|
|
$objectFactory->convertAces($removeAces) |
139
|
|
|
); |
140
|
|
|
|
141
|
|
|
// remove PWC from cache, it doesn't exist anymore |
142
|
|
|
$this->getSession()->removeObjectFromCache($this); |
143
|
|
|
|
144
|
|
|
if ($newObjectId === null) { |
145
|
|
|
return null; |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
return $this->getSession()->createObjectId($newObjectId); |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
/** |
152
|
|
|
* Checks out the document and returns the object ID of the PWC (private working copy). |
153
|
|
|
* |
154
|
|
|
* @return ObjectIdInterface|null PWC object ID |
155
|
|
|
*/ |
156
|
|
|
public function checkOut() |
157
|
|
|
{ |
158
|
|
|
$newObjectId = $this->getId(); |
159
|
|
|
|
160
|
|
|
$this->getBinding()->getVersioningService()->checkOut($this->getRepositoryId(), $newObjectId); |
161
|
|
|
|
162
|
|
|
if ($newObjectId === null) { |
163
|
|
|
return null; |
164
|
|
|
} |
165
|
|
|
|
166
|
|
|
return $this->getSession()->createObjectId($newObjectId); |
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
/** |
170
|
|
|
* Creates a copy of this document, including content. |
171
|
|
|
* |
172
|
|
|
* @param ObjectIdInterface|null $targetFolderId the ID of the target folder, <code>null</code> to create an unfiled |
173
|
|
|
* document |
174
|
|
|
* @param array $properties The property values that MUST be applied to the object. This list of properties SHOULD |
175
|
|
|
* only contain properties whose values differ from the source document. The array key is the property name |
176
|
|
|
* the value is the property value. |
177
|
|
|
* @param VersioningState|null $versioningState An enumeration specifying what the versioning state of the |
178
|
|
|
* newly-created object MUST be. Valid values are: |
179
|
|
|
* <code>none</code> |
180
|
|
|
* (default, if the object-type is not versionable) The document MUST be created as a non-versionable |
181
|
|
|
* document. |
182
|
|
|
* <code>checkedout</code> |
183
|
|
|
* The document MUST be created in the checked-out state. The checked-out document MAY be |
184
|
|
|
* visible to other users. |
185
|
|
|
* <code>major</code> |
186
|
|
|
* (default, if the object-type is versionable) The document MUST be created as a major version. |
187
|
|
|
* <code>minor</code> |
188
|
|
|
* The document MUST be created as a minor version. |
189
|
|
|
* @param PolicyInterface[] $policies A list of policy ids that MUST be applied to the newly-created document |
190
|
|
|
* object. |
191
|
|
|
* @param AceInterface[] $addAces A list of ACEs that MUST be added to the newly-created document object, either |
192
|
|
|
* using the ACL from folderId if specified, or being applied if no folderId is specified. |
193
|
|
|
* @param AceInterface[] $removeAces A list of ACEs that MUST be removed from the newly-created document object, |
194
|
|
|
* either using the ACL from folderId if specified, or being ignored if no folderId is specified. |
195
|
|
|
* @param OperationContextInterface|null $context |
196
|
|
|
* @return DocumentInterface the new document object or <code>null</code> if the parameter <code>context</code> was |
197
|
|
|
* set to <code>null</code> |
198
|
|
|
* @throws CmisRuntimeException Exception is thrown if the created object is not a document |
199
|
|
|
*/ |
200
|
|
|
public function copy( |
201
|
|
|
ObjectIdInterface $targetFolderId = null, |
202
|
|
|
array $properties = [], |
203
|
|
|
VersioningState $versioningState = null, |
204
|
|
|
array $policies = [], |
205
|
|
|
array $addAces = [], |
206
|
|
|
array $removeAces = [], |
207
|
|
|
OperationContextInterface $context = null |
208
|
|
|
) { |
209
|
|
|
try { |
210
|
|
|
$newObjectId = $this->getSession()->createDocumentFromSource( |
211
|
|
|
$this, |
212
|
|
|
$properties, |
213
|
|
|
$targetFolderId, |
214
|
|
|
$versioningState, |
215
|
|
|
$policies, |
216
|
|
|
$addAces, |
217
|
|
|
$removeAces |
218
|
|
|
); |
219
|
|
|
} catch (CmisNotSupportedException $notSupportedException) { |
220
|
|
|
$newObjectId = $this->copyViaClient( |
221
|
|
|
$targetFolderId, |
222
|
|
|
$properties, |
223
|
|
|
$versioningState, |
224
|
|
|
$policies, |
225
|
|
|
$addAces, |
226
|
|
|
$removeAces |
227
|
|
|
); |
228
|
|
|
} |
229
|
|
|
|
230
|
|
|
$document = $this->getNewlyCreatedObject($newObjectId, $context); |
231
|
|
|
|
232
|
|
|
if ($document === null) { |
233
|
|
|
return null; |
234
|
|
|
} elseif (!$document instanceof DocumentInterface) { |
235
|
|
|
throw new CmisRuntimeException('Newly created object is not a document! New id: ' . $document->getId()); |
236
|
|
|
} |
237
|
|
|
|
238
|
|
|
return $document; |
239
|
|
|
} |
240
|
|
|
|
241
|
|
|
/** |
242
|
|
|
* Copies the document manually. The content is streamed from the repository and back. |
243
|
|
|
* |
244
|
|
|
* @param ObjectIdInterface|null $targetFolderId the ID of the target folder, <code>null</code> to create an unfiled |
245
|
|
|
* document |
246
|
|
|
* @param array $properties The property values that MUST be applied to the object. This list of properties SHOULD |
247
|
|
|
* only contain properties whose values differ from the source document. The array key is the property name |
248
|
|
|
* the value is the property value. |
249
|
|
|
* @param VersioningState|null $versioningState An enumeration specifying what the versioning state of the |
250
|
|
|
* newly-created object MUST be. Valid values are: |
251
|
|
|
* <code>none</code> |
252
|
|
|
* (default, if the object-type is not versionable) The document MUST be created as a non-versionable |
253
|
|
|
* document. |
254
|
|
|
* <code>checkedout</code> |
255
|
|
|
* The document MUST be created in the checked-out state. The checked-out document MAY be |
256
|
|
|
* visible to other users. |
257
|
|
|
* <code>major</code> |
258
|
|
|
* (default, if the object-type is versionable) The document MUST be created as a major version. |
259
|
|
|
* <code>minor</code> |
260
|
|
|
* The document MUST be created as a minor version. |
261
|
|
|
* @param PolicyInterface[] $policies A list of policy ids that MUST be applied to the newly-created document |
262
|
|
|
* object. |
263
|
|
|
* @param AceInterface[] $addAces A list of ACEs that MUST be added to the newly-created document object, either |
264
|
|
|
* using the ACL from folderId if specified, or being applied if no folderId is specified. |
265
|
|
|
* @param AceInterface[] $removeAces A list of ACEs that MUST be removed from the newly-created document object, |
266
|
|
|
* either using the ACL from folderId if specified, or being ignored if no folderId is specified. |
267
|
|
|
* @return ObjectIdInterface The id of the newly-created document. |
268
|
|
|
* @throws CmisRuntimeException |
269
|
|
|
*/ |
270
|
|
|
protected function copyViaClient( |
271
|
|
|
ObjectIdInterface $targetFolderId = null, |
272
|
|
|
array $properties = [], |
273
|
|
|
VersioningState $versioningState = null, |
274
|
|
|
array $policies = [], |
275
|
|
|
array $addAces = [], |
276
|
|
|
array $removeAces = [] |
277
|
|
|
) { |
278
|
|
|
$newProperties = []; |
279
|
|
|
|
280
|
|
|
$allPropertiesContext = $this->getSession()->createOperationContext(); |
281
|
|
|
$allPropertiesContext->setFilterString('*'); |
282
|
|
|
$allPropertiesContext->setIncludeAcls(false); |
283
|
|
|
$allPropertiesContext->setIncludeAllowableActions(false); |
284
|
|
|
$allPropertiesContext->setIncludePathSegments(false); |
285
|
|
|
$allPropertiesContext->setIncludePolicies(false); |
286
|
|
|
$allPropertiesContext->setIncludeRelationships(IncludeRelationships::cast(IncludeRelationships::NONE)); |
287
|
|
|
$allPropertiesContext->setRenditionFilterString(Constants::RENDITION_NONE); |
288
|
|
|
|
289
|
|
|
$allPropertiesDocument = $this->getSession()->getObject($this, $allPropertiesContext); |
290
|
|
|
if (! $allPropertiesDocument instanceof DocumentInterface) { |
291
|
|
|
throw new CmisRuntimeException('Returned object is not of expected type DocumentInterface'); |
292
|
|
|
} |
293
|
|
|
|
294
|
|
|
foreach ($allPropertiesDocument->getProperties() as $property) { |
295
|
|
|
if (Updatability::cast(Updatability::READWRITE)->equals($property->getDefinition()->getUpdatability()) |
296
|
|
|
|| Updatability::cast(Updatability::ONCREATE)->equals($property->getDefinition()->getUpdatability()) |
297
|
|
|
) { |
298
|
|
|
$newProperties[$property->getId()] = $property->isMultiValued() ? $property->getValues( |
299
|
|
|
) : $property->getFirstValue(); |
300
|
|
|
} |
301
|
|
|
} |
302
|
|
|
|
303
|
|
|
$newProperties = array_merge($newProperties, $properties); |
304
|
|
|
$contentStream = $allPropertiesDocument->getContentStream(); |
305
|
|
|
|
306
|
|
|
return $this->getSession()->createDocument( |
307
|
|
|
$newProperties, |
308
|
|
|
$targetFolderId, |
309
|
|
|
$contentStream, |
310
|
|
|
$versioningState, |
311
|
|
|
$policies, |
312
|
|
|
$addAces, |
313
|
|
|
$removeAces |
314
|
|
|
); |
315
|
|
|
} |
316
|
|
|
|
317
|
|
|
/** |
318
|
|
|
* Deletes this document and all its versions. |
319
|
|
|
*/ |
320
|
|
|
public function deleteAllVersions() |
321
|
|
|
{ |
322
|
|
|
$this->delete(true); |
323
|
|
|
} |
324
|
|
|
|
325
|
|
|
/** |
326
|
|
|
* Removes the current content stream from the document and refreshes this object afterwards. |
327
|
|
|
* |
328
|
|
|
* @param boolean $refresh if this parameter is set to <code>true</code>, this object will be refreshed after the |
329
|
|
|
* content stream has been deleted |
330
|
|
|
* @return DocumentInterface|null the updated document, or <code>null</code> if the repository did not return |
331
|
|
|
* an object ID |
332
|
|
|
*/ |
333
|
|
View Code Duplication |
public function deleteContentStream($refresh = true) |
|
|
|
|
334
|
|
|
{ |
335
|
|
|
$newObjectId = $this->getId(); |
336
|
|
|
$changeToken = $this->getPropertyValue(PropertyIds::CHANGE_TOKEN); |
337
|
|
|
|
338
|
|
|
$this->getBinding()->getObjectService()->deleteContentStream( |
339
|
|
|
$this->getRepositoryId(), |
340
|
|
|
$newObjectId, |
341
|
|
|
$changeToken |
342
|
|
|
); |
343
|
|
|
|
344
|
|
|
if ($refresh === true) { |
345
|
|
|
$this->refresh(); |
346
|
|
|
} |
347
|
|
|
|
348
|
|
|
if ($newObjectId === null) { |
349
|
|
|
return null; |
350
|
|
|
} |
351
|
|
|
|
352
|
|
|
return $this->getSession()->getObject( |
353
|
|
|
$this->getSession()->createObjectId($newObjectId), |
354
|
|
|
$this->getCreationContext() |
355
|
|
|
); |
356
|
|
|
} |
357
|
|
|
|
358
|
|
|
/** |
359
|
|
|
* Fetches all versions of this document using the given OperationContext. |
360
|
|
|
* The behavior of this method is undefined if the document is not versionable |
361
|
|
|
* and can be different for each repository. |
362
|
|
|
* |
363
|
|
|
* @param OperationContextInterface|null $context |
364
|
|
|
* @return DocumentInterface[] |
365
|
|
|
*/ |
366
|
|
|
public function getAllVersions(OperationContextInterface $context = null) |
367
|
|
|
{ |
368
|
|
|
$context = $this->ensureContext($context); |
369
|
|
|
$versions = $this->getBinding()->getVersioningService()->getAllVersions( |
370
|
|
|
$this->getRepositoryId(), |
371
|
|
|
$this->getId(), |
372
|
|
|
$this->getVersionSeriesId(), |
373
|
|
|
$context->getQueryFilterString(), |
374
|
|
|
$context->isIncludeAllowableActions() |
375
|
|
|
); |
376
|
|
|
|
377
|
|
|
$objectFactory = $this->getSession()->getObjectFactory(); |
378
|
|
|
$result = []; |
379
|
|
|
if (count($versions)) { |
380
|
|
|
foreach ($versions as $objectData) { |
381
|
|
|
$document = $objectFactory->convertObject($objectData, $context); |
382
|
|
|
if (!($document instanceof DocumentInterface)) { |
383
|
|
|
throw new CmisVersioningException( |
384
|
|
|
sprintf( |
385
|
|
|
'Repository yielded non-Document %s as version of Document %s - unsupported repository response', |
386
|
|
|
$document->getId(), |
387
|
|
|
$this->getId() |
388
|
|
|
) |
389
|
|
|
); |
390
|
|
|
} |
391
|
|
|
$result[] = $document; |
392
|
|
|
} |
393
|
|
|
} |
394
|
|
|
|
395
|
|
|
return $result; |
396
|
|
|
} |
397
|
|
|
|
398
|
|
|
/** |
399
|
|
|
* Returns the content URL of the document or a rendition if the binding |
400
|
|
|
* supports content URLs. |
401
|
|
|
* |
402
|
|
|
* Depending on the repository and the binding, the server might not return |
403
|
|
|
* the content but an error message. Authentication data is not attached. |
404
|
|
|
* That is, a user may have to re-authenticate to get the content. |
405
|
|
|
* |
406
|
|
|
* @param string|null $streamId the ID of the rendition or <code>null</code> for the document |
407
|
|
|
* |
408
|
|
|
* @return string|null the content URL of the document or rendition or <code>null</code> if |
409
|
|
|
* the binding does not support content URLs |
410
|
|
|
*/ |
411
|
|
|
public function getContentUrl($streamId = null) |
412
|
|
|
{ |
413
|
|
|
$objectService = $this->getBinding()->getObjectService(); |
414
|
|
|
if ($objectService instanceof LinkAccessInterface) { |
415
|
|
|
if ($streamId === null) { |
416
|
|
|
return $objectService->loadContentLink($this->getRepositoryId(), $this->getId()); |
417
|
|
|
} else { |
418
|
|
|
return $objectService->loadRenditionContentLink($this->getRepositoryId(), $this->getId(), $streamId); |
419
|
|
|
} |
420
|
|
|
} |
421
|
|
|
|
422
|
|
|
return null; |
423
|
|
|
} |
424
|
|
|
|
425
|
|
|
/** |
426
|
|
|
* Retrieves the content stream that is associated with the given stream ID. |
427
|
|
|
* This is usually a rendition of the document. |
428
|
|
|
* |
429
|
|
|
* @param string|null $streamId the stream ID |
430
|
|
|
* @param integer|null $offset the offset of the stream or <code>null</code> to read the stream from the beginning |
431
|
|
|
* @param integer|null $length the maximum length of the stream or <code>null</code> to read to the end of the |
432
|
|
|
* stream |
433
|
|
|
* @return StreamInterface|null the content stream, or <code>null</code> if no content is associated with this |
434
|
|
|
* stream ID |
435
|
|
|
*/ |
436
|
|
|
public function getContentStream($streamId = null, $offset = null, $length = null) |
437
|
|
|
{ |
438
|
|
|
return $this->getSession()->getContentStream($this, $streamId, $offset, $length); |
439
|
|
|
} |
440
|
|
|
|
441
|
|
|
/** |
442
|
|
|
* Fetches the latest major or minor version of this document using the given OperationContext. |
443
|
|
|
* |
444
|
|
|
* @param boolean $major if <code>true</code> the latest major version will be returned, |
445
|
|
|
* otherwise the very last version will be returned |
446
|
|
|
* @param OperationContextInterface|null $context |
447
|
|
|
* @return DocumentInterface the latest document object |
448
|
|
|
*/ |
449
|
|
|
public function getObjectOfLatestVersion($major, OperationContextInterface $context = null) |
450
|
|
|
{ |
451
|
|
|
$context = $this->ensureContext($context); |
452
|
|
|
|
453
|
|
|
return $this->getSession()->getLatestDocumentVersion($this, $major, $context); |
454
|
|
|
} |
455
|
|
|
|
456
|
|
|
/** |
457
|
|
|
* Sets a new content stream for the document. If the repository created a new version, |
458
|
|
|
* the object ID of this new version is returned. Otherwise the object ID of the current document is returned. |
459
|
|
|
* The stream in contentStream is consumed but not closed by this method. |
460
|
|
|
* |
461
|
|
|
* @param StreamInterface $contentStream the content stream |
462
|
|
|
* @param boolean $overwrite if this parameter is set to <code>false</code> and the document already has content, |
463
|
|
|
* the repository throws a CmisContentAlreadyExistsException |
464
|
|
|
* @param boolean $refresh if this parameter is set to <code>true</code>, this object will be refreshed |
465
|
|
|
* after the new content has been set |
466
|
|
|
* @return ObjectIdInterface|null the updated object ID, or <code>null</code> if the repository did not return |
467
|
|
|
* an object ID |
468
|
|
|
*/ |
469
|
|
View Code Duplication |
public function setContentStream(StreamInterface $contentStream, $overwrite, $refresh = true) |
|
|
|
|
470
|
|
|
{ |
471
|
|
|
$newObjectId = $this->getId(); |
472
|
|
|
$changeToken = $this->getPropertyValue(PropertyIds::CHANGE_TOKEN); |
473
|
|
|
|
474
|
|
|
$this->getBinding()->getObjectService()->setContentStream( |
475
|
|
|
$this->getRepositoryId(), |
476
|
|
|
$newObjectId, |
477
|
|
|
$this->getObjectFactory()->convertContentStream($contentStream), |
478
|
|
|
$overwrite, |
479
|
|
|
$changeToken |
480
|
|
|
); |
481
|
|
|
|
482
|
|
|
if ($refresh === true) { |
483
|
|
|
$this->refresh(); |
484
|
|
|
} |
485
|
|
|
|
486
|
|
|
if ($newObjectId === null) { |
487
|
|
|
return null; |
488
|
|
|
} |
489
|
|
|
|
490
|
|
|
return $this->getSession()->createObjectId($newObjectId); |
491
|
|
|
} |
492
|
|
|
|
493
|
|
|
/** |
494
|
|
|
* Returns the checkin comment (CMIS property cmis:checkinComment). |
495
|
|
|
* |
496
|
|
|
* @return string|null the checkin comment of this version or <code>null</code> if the property hasn't |
497
|
|
|
* been requested, hasn't been provided by the repository, or the property value isn't set |
498
|
|
|
*/ |
499
|
|
|
public function getCheckinComment() |
500
|
|
|
{ |
501
|
|
|
return $this->getPropertyValue(PropertyIds::CHECKIN_COMMENT); |
502
|
|
|
} |
503
|
|
|
|
504
|
|
|
/** |
505
|
|
|
* Returns the content stream filename or <code>null</code> if the document has no content |
506
|
|
|
* (CMIS property cmis:contentStreamFileName). |
507
|
|
|
* |
508
|
|
|
* @return string|null the content stream filename of this document or <code>null</code> if the property hasn't |
509
|
|
|
* been requested, hasn't been provided by the repository, or the document has no content |
510
|
|
|
*/ |
511
|
|
|
public function getContentStreamFileName() |
512
|
|
|
{ |
513
|
|
|
return $this->getPropertyValue(PropertyIds::CONTENT_STREAM_FILE_NAME); |
514
|
|
|
} |
515
|
|
|
|
516
|
|
|
/** |
517
|
|
|
* Returns the content hashes or <code>null</code> if the document has no content |
518
|
|
|
* (CMIS property cmis:contentStreamHash). |
519
|
|
|
* |
520
|
|
|
* @return ContentStreamHashInterface[]|null the list of content hashes or <code>null</code> if the property |
521
|
|
|
* hasn't been requested, hasn't been provided by the repository, or the document has no content |
522
|
|
|
*/ |
523
|
|
|
public function getContentStreamHashes() |
524
|
|
|
{ |
525
|
|
|
return null; |
526
|
|
|
// TODO: Implement getContentStreamHashes() method. |
527
|
|
|
// TODO: Check if ContentStreamHashInterface is required and has to be implemented |
528
|
|
|
} |
529
|
|
|
|
530
|
|
|
/** |
531
|
|
|
* Returns the content stream ID or <code>null</code> if the document has no content |
532
|
|
|
* (CMIS property cmis:contentStreamId). |
533
|
|
|
* |
534
|
|
|
* @return string|null the content stream ID of this document or <code>null</code> if the property hasn't |
535
|
|
|
* been requested, hasn't been provided by the repository, or the document has no content |
536
|
|
|
*/ |
537
|
|
|
public function getContentStreamId() |
538
|
|
|
{ |
539
|
|
|
return $this->getPropertyValue(PropertyIds::CONTENT_STREAM_ID); |
540
|
|
|
} |
541
|
|
|
|
542
|
|
|
/** |
543
|
|
|
* Returns the content stream length or <code>null</code> if the document has no content (CMIS property |
544
|
|
|
* cmis:contentStreamLength). |
545
|
|
|
* |
546
|
|
|
* @return integer the content stream length of this document or <code>null</code> if the property hasn't been |
547
|
|
|
* requested, hasn't been provided by the repository, or the document has no content |
548
|
|
|
*/ |
549
|
|
|
public function getContentStreamLength() |
550
|
|
|
{ |
551
|
|
|
return $this->getPropertyValue(PropertyIds::CONTENT_STREAM_LENGTH); |
552
|
|
|
} |
553
|
|
|
|
554
|
|
|
/** |
555
|
|
|
* Returns the content stream MIME type or <code>null</code> if the document has no content |
556
|
|
|
* (CMIS property cmis:contentStreamMimeType). |
557
|
|
|
* |
558
|
|
|
* @return string|null the content stream MIME type of this document or <code>null</code> if the property hasn't |
559
|
|
|
* been requested, hasn't been provided by the repository, or the document has no content |
560
|
|
|
*/ |
561
|
|
|
public function getContentStreamMimeType() |
562
|
|
|
{ |
563
|
|
|
return $this->getPropertyValue(PropertyIds::CONTENT_STREAM_MIME_TYPE); |
564
|
|
|
} |
565
|
|
|
|
566
|
|
|
/** |
567
|
|
|
* Returns the version label (CMIS property cmis:versionLabel). |
568
|
|
|
* |
569
|
|
|
* @return string|null the version label of the document or <code>null</code> if the property hasn't been requested, |
570
|
|
|
* hasn't been provided by the repository, or the property value isn't set |
571
|
|
|
*/ |
572
|
|
|
public function getVersionLabel() |
573
|
|
|
{ |
574
|
|
|
return $this->getPropertyValue(PropertyIds::VERSION_LABEL); |
575
|
|
|
} |
576
|
|
|
|
577
|
|
|
/** |
578
|
|
|
* Returns the user who checked out this version series (CMIS property cmis:versionSeriesCheckedOutBy). |
579
|
|
|
* |
580
|
|
|
* @return string|null the user who checked out this version series or <code>null</code> if the property hasn't |
581
|
|
|
* been requested, hasn't been provided by the repository, or the property value isn't set |
582
|
|
|
*/ |
583
|
|
|
public function getVersionSeriesCheckedOutBy() |
584
|
|
|
{ |
585
|
|
|
return $this->getPropertyValue(PropertyIds::VERSION_SERIES_CHECKED_OUT_BY); |
586
|
|
|
} |
587
|
|
|
|
588
|
|
|
/** |
589
|
|
|
* Returns the PWC ID of this version series (CMIS property cmis:versionSeriesCheckedOutId). |
590
|
|
|
* Some repositories provided this value only to the user who checked out the version series. |
591
|
|
|
* |
592
|
|
|
* @return string|null the PWC ID of this version series or <code>null</code> if the property hasn't been requested, |
593
|
|
|
* hasn't been provided by the repository, or the property value isn't set |
594
|
|
|
*/ |
595
|
|
|
public function getVersionSeriesCheckedOutId() |
596
|
|
|
{ |
597
|
|
|
return $this->getPropertyValue(PropertyIds::VERSION_SERIES_CHECKED_OUT_ID); |
598
|
|
|
} |
599
|
|
|
|
600
|
|
|
/** |
601
|
|
|
* Returns the version series ID (CMIS property cmis:versionSeriesId). |
602
|
|
|
* |
603
|
|
|
* @return string|null the version series ID of the document or <code>null</code> if the property hasn't |
604
|
|
|
* been requested, hasn't been provided by the repository, or the property value isn't set |
605
|
|
|
*/ |
606
|
|
|
public function getVersionSeriesId() |
607
|
|
|
{ |
608
|
|
|
return $this->getPropertyValue(PropertyIds::VERSION_SERIES_ID); |
609
|
|
|
} |
610
|
|
|
|
611
|
|
|
/** |
612
|
|
|
* Returns <code>true</code> if this document is immutable (CMIS property cmis:isImmutable). |
613
|
|
|
* |
614
|
|
|
* @return boolean|null the immutable flag of the document or <code>null</code> if the property hasn't |
615
|
|
|
* been requested, hasn't been provided by the repository, or the property value isn't set |
616
|
|
|
*/ |
617
|
|
|
public function isImmutable() |
618
|
|
|
{ |
619
|
|
|
return $this->getPropertyValue(PropertyIds::IS_IMMUTABLE); |
620
|
|
|
} |
621
|
|
|
|
622
|
|
|
/** |
623
|
|
|
* Returns <code>true</code> if this document is the latest version (CMIS property cmis:isLatestVersion). |
624
|
|
|
* |
625
|
|
|
* @return boolean|null the latest version flag of the document or <code>null</code> if the property hasn't |
626
|
|
|
* been requested, hasn't been provided by the repository, or the property value isn't set |
627
|
|
|
*/ |
628
|
|
|
public function isLatestMajorVersion() |
629
|
|
|
{ |
630
|
|
|
return $this->getPropertyValue(PropertyIds::IS_LATEST_MAJOR_VERSION); |
631
|
|
|
} |
632
|
|
|
|
633
|
|
|
/** |
634
|
|
|
* Returns <code>true</code> if this document is the latest version (CMIS property cmis:isLatestVersion). |
635
|
|
|
* |
636
|
|
|
* @return boolean|null the latest version flag of the document or <code>null</code> if the property hasn't |
637
|
|
|
* been requested, hasn't been provided by the repository, or the property value isn't set |
638
|
|
|
*/ |
639
|
|
|
public function isLatestVersion() |
640
|
|
|
{ |
641
|
|
|
return $this->getPropertyValue(PropertyIds::IS_LATEST_VERSION); |
642
|
|
|
} |
643
|
|
|
|
644
|
|
|
/** |
645
|
|
|
* Returns <code>true</code> if this document is a major version (CMIS property cmis:isMajorVersion). |
646
|
|
|
* |
647
|
|
|
* @return boolean|null the major version flag of the document or <code>null</code> if the property hasn't |
648
|
|
|
* been requested, hasn't been provided by the repository, or the property value isn't set |
649
|
|
|
*/ |
650
|
|
|
public function isMajorVersion() |
651
|
|
|
{ |
652
|
|
|
return $this->getPropertyValue(PropertyIds::IS_MAJOR_VERSION); |
653
|
|
|
} |
654
|
|
|
|
655
|
|
|
/** |
656
|
|
|
* Returns <code>true</code> if this document is the PWC (CMIS property cmis:isPrivateWorkingCopy). |
657
|
|
|
* |
658
|
|
|
* @return boolean|null the PWC flag of the document or <code>null</code> if the property hasn't been requested, |
659
|
|
|
* hasn't been provided by the repository, or the property value isn't set |
660
|
|
|
*/ |
661
|
|
|
public function isPrivateWorkingCopy() |
662
|
|
|
{ |
663
|
|
|
return $this->getPropertyValue(PropertyIds::IS_PRIVATE_WORKING_COPY); |
664
|
|
|
} |
665
|
|
|
|
666
|
|
|
/** |
667
|
|
|
* Returns <code>true</code> if this version series is checked out (CMIS property cmis:isVersionSeriesCheckedOut). |
668
|
|
|
* |
669
|
|
|
* @return boolean|null the version series checked out flag of the document or <code>null</code> if the property |
670
|
|
|
* hasn't been requested, hasn't been provided by the repository, or the property value isn't set |
671
|
|
|
*/ |
672
|
|
|
public function isVersionSeriesCheckedOut() |
673
|
|
|
{ |
674
|
|
|
return $this->getPropertyValue(PropertyIds::IS_VERSION_SERIES_CHECKED_OUT); |
675
|
|
|
} |
676
|
|
|
} |
677
|
|
|
|