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; |
15
|
|
|
use Dkd\PhpCmis\Data\ExtensionDataInterface; |
16
|
|
|
use Dkd\PhpCmis\Data\ObjectListInterface; |
17
|
|
|
use Dkd\PhpCmis\DiscoveryServiceInterface; |
18
|
|
|
use Dkd\PhpCmis\Enum; |
19
|
|
|
use Dkd\PhpCmis\Enum\IncludeRelationships; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Discovery Service Browser Binding client. |
23
|
|
|
*/ |
24
|
|
|
class DiscoveryService extends AbstractBrowserBindingService implements DiscoveryServiceInterface |
25
|
|
|
{ |
26
|
|
|
/** |
27
|
|
|
* Gets a list of content changes. |
28
|
|
|
* |
29
|
|
|
* @param string $repositoryId The identifier for the repository. |
30
|
|
|
* @param string|null $changeLogToken If specified, then the repository MUST return the change event corresponding |
31
|
|
|
* to the value of the specified change log token as the first result in the output. |
32
|
|
|
* If not specified, then the repository MUST return the first change event recorded in the change log. |
33
|
|
|
* @param boolean $includeProperties If <code>true</code>, then the repository MUST include the updated property |
34
|
|
|
* values for "updated" change events if the repository supports returning property values as specified by |
35
|
|
|
* capbilityChanges. |
36
|
|
|
* If <code>false</code>, then the repository MUST NOT include the updated property values for |
37
|
|
|
* "updated" change events. The single exception to this is that the property cmis:objectId MUST always |
38
|
|
|
* be included. |
39
|
|
|
* @param boolean $includePolicyIds If <code>true</code>, then the repository MUST include the ids of the policies |
40
|
|
|
* applied to the object referenced in each change event, if the change event modified the set of policies |
41
|
|
|
* applied to the object. |
42
|
|
|
* If <code>false</code>, then the repository MUST not include policy information. |
43
|
|
|
* @param boolean $includeAcl If <code>true</code>, then the repository MUST return the ACLs for each object in the |
44
|
|
|
* result set. Defaults to <code>false</code>. |
45
|
|
|
* @param integer|null $maxItems the maximum number of items to return in a response |
46
|
|
|
* (default is repository specific) |
47
|
|
|
* @param ExtensionDataInterface|null $extension |
48
|
|
|
* @return ObjectListInterface |
49
|
|
|
*/ |
50
|
4 |
|
public function getContentChanges( |
51
|
|
|
$repositoryId, |
52
|
|
|
&$changeLogToken = null, |
53
|
|
|
$includeProperties = false, |
54
|
|
|
$includePolicyIds = false, |
55
|
|
|
$includeAcl = false, |
56
|
|
|
$maxItems = null, |
57
|
|
|
ExtensionDataInterface $extension = null |
58
|
|
|
) { |
59
|
4 |
|
$url = $this->getRepositoryUrl($repositoryId, Constants::SELECTOR_CONTENT_CHANGES); |
60
|
|
|
|
61
|
4 |
|
$url->getQuery()->modify( |
62
|
|
|
[ |
63
|
4 |
|
Constants::PARAM_PROPERTIES => $includeProperties ? 'true' : 'false', |
64
|
4 |
|
Constants::PARAM_POLICY_IDS => $includePolicyIds ? 'true' : 'false', |
65
|
4 |
|
Constants::PARAM_ACL => $includeAcl ? 'true' : 'false', |
66
|
4 |
|
Constants::PARAM_SUCCINCT => $this->getSuccinct() ? 'true' : 'false', |
67
|
|
|
] |
68
|
4 |
|
); |
69
|
|
|
|
70
|
4 |
|
if ($changeLogToken !== null) { |
71
|
2 |
|
$url->getQuery()->modify([Constants::PARAM_CHANGE_LOG_TOKEN => (string) $changeLogToken]); |
72
|
2 |
|
} |
73
|
|
|
|
74
|
4 |
|
if ($maxItems > 0) { |
75
|
2 |
|
$url->getQuery()->modify([Constants::PARAM_MAX_ITEMS => (string) $maxItems]); |
76
|
2 |
|
} |
77
|
|
|
|
78
|
4 |
|
$responseData = (array) \json_decode($this->read($url)->getBody(), true); |
79
|
|
|
|
80
|
|
|
// $changeLogToken was passed by reference. The value is changed here |
81
|
4 |
|
$changeLogToken = $responseData[JSONConstants::JSON_OBJECTLIST_CHANGE_LOG_TOKEN] ?? null; |
82
|
|
|
|
83
|
|
|
// TODO Implement Cache |
84
|
|
|
return $this->getJsonConverter()->convertObjectList($responseData); |
85
|
|
|
} |
86
|
4 |
|
|
87
|
|
|
/** |
88
|
|
|
* Executes a CMIS query statement against the contents of the repository. |
89
|
|
|
* |
90
|
|
|
* @param string $repositoryId The identifier for the repository. |
91
|
|
|
* @param string $statement CMIS query to be executed |
92
|
|
|
* @param boolean $searchAllVersions If <code>true</code>, then the repository MUST include latest and non-latest |
93
|
|
|
* versions of document objects in the query search scope. |
94
|
|
|
* If <code>false</code>, then the repository MUST only include latest versions of documents in the |
95
|
|
|
* query search scope. |
96
|
|
|
* If the repository does not support the optional capabilityAllVersionsSearchable capability, then this |
97
|
|
|
* parameter value MUST be set to <code>false</code>. |
98
|
|
|
* @param IncludeRelationships|null $includeRelationships indicates what relationships in which the objects |
99
|
|
|
* participate must be returned (default is <code>IncludeRelationships::NONE</code>) |
100
|
|
|
* @param string $renditionFilter The Repository MUST return the set of renditions whose kind matches this |
101
|
|
|
* filter. See section below for the filter grammar. Defaults to "cmis:none". |
102
|
|
|
* @param boolean $includeAllowableActions if <code>true</code>, then the repository must return the available |
103
|
|
|
* actions for each object in the result set (default is <code>false</code>) |
104
|
|
|
* @param integer|null $maxItems the maximum number of items to return in a response |
105
|
|
|
* (default is repository specific) |
106
|
|
|
* @param integer $skipCount number of potential results that the repository MUST skip/page over before |
107
|
|
|
* returning any results (default is 0) |
108
|
|
|
* @param ExtensionDataInterface|null $extension |
109
|
|
|
* @return ObjectListInterface|null Returns object of type <code>ObjectListInterface</code> |
110
|
|
|
* or <code>null</code> if the repository response was empty |
111
|
|
|
*/ |
112
|
|
|
public function query( |
113
|
|
|
$repositoryId, |
114
|
9 |
|
$statement, |
115
|
|
|
$searchAllVersions = false, |
116
|
|
|
IncludeRelationships $includeRelationships = null, |
117
|
|
|
$renditionFilter = Constants::RENDITION_NONE, |
118
|
|
|
$includeAllowableActions = false, |
119
|
|
|
$maxItems = null, |
120
|
|
|
$skipCount = 0, |
121
|
|
|
ExtensionDataInterface $extension = null |
122
|
|
|
) { |
123
|
|
|
$url = $this->getRepositoryUrl($repositoryId); |
124
|
|
|
|
125
|
9 |
|
$url->getQuery()->modify( |
126
|
|
|
[ |
127
|
9 |
|
Constants::CONTROL_CMISACTION => Constants::CMISACTION_QUERY, |
128
|
|
|
Constants::PARAM_STATEMENT => (string) $statement, |
129
|
9 |
|
Constants::PARAM_SEARCH_ALL_VERSIONS => $searchAllVersions ? 'true' : 'false', |
130
|
9 |
|
Constants::PARAM_ALLOWABLE_ACTIONS => $includeAllowableActions ? 'true' : 'false', |
131
|
9 |
|
Constants::PARAM_RENDITION_FILTER => $renditionFilter, |
132
|
9 |
|
Constants::PARAM_SKIP_COUNT => (string) $skipCount, |
133
|
9 |
|
Constants::PARAM_DATETIME_FORMAT => (string) $this->getDateTimeFormat() |
134
|
9 |
|
] |
135
|
9 |
|
); |
136
|
9 |
|
|
137
|
9 |
|
if ($includeRelationships !== null) { |
138
|
|
|
$url->getQuery()->modify([Constants::PARAM_RELATIONSHIPS => (string) $includeRelationships]); |
139
|
9 |
|
} |
140
|
6 |
|
|
141
|
6 |
|
if ($maxItems > 0) { |
142
|
|
|
$url->getQuery()->modify([Constants::PARAM_MAX_ITEMS => (string) $maxItems]); |
143
|
9 |
|
} |
144
|
3 |
|
|
145
|
3 |
|
$responseData = (array) \json_decode($this->post($url)->getBody(), true); |
146
|
|
|
|
147
|
9 |
|
return $this->getJsonConverter()->convertQueryResultList($responseData); |
148
|
|
|
} |
149
|
|
|
} |
150
|
|
|
|