|
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
|
|
|
array( |
|
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(array(Constants::PARAM_CHANGE_LOG_TOKEN => (string) $changeLogToken)); |
|
72
|
2 |
|
} |
|
73
|
|
|
|
|
74
|
4 |
|
if ($maxItems > 0) { |
|
75
|
2 |
|
$url->getQuery()->modify(array(Constants::PARAM_MAX_ITEMS => (string) $maxItems)); |
|
76
|
2 |
|
} |
|
77
|
|
|
|
|
78
|
4 |
|
$responseData = $this->read($url)->json(); |
|
79
|
|
|
|
|
80
|
|
|
// $changeLogToken was passed by reference. The value is changed here |
|
81
|
4 |
|
if ($changeLogToken!==null && isset($responseData[JSONConstants::JSON_OBJECTLIST_CHANGE_LOG_TOKEN])) { |
|
82
|
|
|
$changeLogToken = (string) $responseData[JSONConstants::JSON_OBJECTLIST_CHANGE_LOG_TOKEN]; |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
// TODO Implement Cache |
|
86
|
4 |
|
return $this->getJsonConverter()->convertObjectList($responseData); |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* Executes a CMIS query statement against the contents of the repository. |
|
91
|
|
|
* |
|
92
|
|
|
* @param string $repositoryId The identifier for the repository. |
|
93
|
|
|
* @param string $statement CMIS query to be executed |
|
94
|
|
|
* @param boolean $searchAllVersions If <code>true</code>, then the repository MUST include latest and non-latest |
|
95
|
|
|
* versions of document objects in the query search scope. |
|
96
|
|
|
* If <code>false</code>, then the repository MUST only include latest versions of documents in the |
|
97
|
|
|
* query search scope. |
|
98
|
|
|
* If the repository does not support the optional capabilityAllVersionsSearchable capability, then this |
|
99
|
|
|
* parameter value MUST be set to <code>false</code>. |
|
100
|
|
|
* @param IncludeRelationships|null $includeRelationships indicates what relationships in which the objects |
|
101
|
|
|
* participate must be returned (default is <code>IncludeRelationships::NONE</code>) |
|
102
|
|
|
* @param string $renditionFilter The Repository MUST return the set of renditions whose kind matches this |
|
103
|
|
|
* filter. See section below for the filter grammar. Defaults to "cmis:none". |
|
104
|
|
|
* @param boolean $includeAllowableActions if <code>true</code>, then the repository must return the available |
|
105
|
|
|
* actions for each object in the result set (default is <code>false</code>) |
|
106
|
|
|
* @param integer|null $maxItems the maximum number of items to return in a response |
|
107
|
|
|
* (default is repository specific) |
|
108
|
|
|
* @param integer $skipCount number of potential results that the repository MUST skip/page over before |
|
109
|
|
|
* returning any results (default is 0) |
|
110
|
|
|
* @param ExtensionDataInterface|null $extension |
|
111
|
|
|
* @return ObjectListInterface|null Returns object of type <code>ObjectListInterface</code> |
|
112
|
|
|
* or <code>null</code> if the repository response was empty |
|
113
|
|
|
*/ |
|
114
|
9 |
|
public function query( |
|
115
|
|
|
$repositoryId, |
|
116
|
|
|
$statement, |
|
117
|
|
|
$searchAllVersions = false, |
|
118
|
|
|
IncludeRelationships $includeRelationships = null, |
|
119
|
|
|
$renditionFilter = Constants::RENDITION_NONE, |
|
120
|
|
|
$includeAllowableActions = false, |
|
121
|
|
|
$maxItems = null, |
|
122
|
|
|
$skipCount = 0, |
|
123
|
|
|
ExtensionDataInterface $extension = null |
|
124
|
|
|
) { |
|
125
|
9 |
|
$url = $this->getRepositoryUrl($repositoryId); |
|
126
|
|
|
|
|
127
|
9 |
|
$url->getQuery()->modify( |
|
128
|
|
|
array( |
|
129
|
9 |
|
Constants::CONTROL_CMISACTION => Constants::CMISACTION_QUERY, |
|
130
|
9 |
|
Constants::PARAM_STATEMENT => (string) $statement, |
|
131
|
9 |
|
Constants::PARAM_SEARCH_ALL_VERSIONS => $searchAllVersions ? 'true' : 'false', |
|
132
|
9 |
|
Constants::PARAM_ALLOWABLE_ACTIONS => $includeAllowableActions ? 'true' : 'false', |
|
133
|
9 |
|
Constants::PARAM_RENDITION_FILTER => $renditionFilter, |
|
134
|
9 |
|
Constants::PARAM_SKIP_COUNT => (string) $skipCount, |
|
135
|
9 |
|
Constants::PARAM_DATETIME_FORMAT => (string) $this->getDateTimeFormat() |
|
136
|
9 |
|
) |
|
137
|
9 |
|
); |
|
138
|
|
|
|
|
139
|
9 |
|
if ($includeRelationships !== null) { |
|
140
|
6 |
|
$url->getQuery()->modify(array(Constants::PARAM_RELATIONSHIPS => (string) $includeRelationships)); |
|
141
|
6 |
|
} |
|
142
|
|
|
|
|
143
|
9 |
|
if ($maxItems > 0) { |
|
144
|
3 |
|
$url->getQuery()->modify(array(Constants::PARAM_MAX_ITEMS => (string) $maxItems)); |
|
145
|
3 |
|
} |
|
146
|
|
|
|
|
147
|
9 |
|
$responseData = $this->post($url)->json(); |
|
148
|
|
|
|
|
149
|
9 |
|
return $this->getJsonConverter()->convertQueryResultList($responseData); |
|
150
|
|
|
} |
|
151
|
|
|
} |
|
152
|
|
|
|