129 $uri = $this->
http->request()->getUri()->getPath();
130 $request = substr($uri, strpos($uri, self::WOPI_BASE_URL) + strlen(self::WOPI_BASE_URL));
131 $request = explode(
'/', $request);
132 $method = $this->
http->request()->getMethod();
134 $resource_id = $request[1];
135 $action = $request[2] ??
'';
138 if ($this->token_resource_id !== $resource_id) {
139 $this->
http->close();
142 $resource_id = $this->irss->manage()->find($resource_id);
143 if (!$resource_id instanceof ResourceIdentification) {
144 $this->
http->close();
146 $resource = $this->irss->manage()->getResource($resource_id);
147 $current_revision = $this->editable ? $resource->getCurrentRevisionIncludingDraft() : $resource->getCurrentRevision();
149 $method_override = $this->
http->request()->getHeader(self::HEADER_X_WOPI_OVERRIDE)[0] ??
null;
150 $is_file_convertion = (bool) ($this->
http->request()->getHeader(
151 self::HEADER_X_WOPI_FILE_CONVERSION
155 switch ($method_override ?? $method) {
162 $this->token_user_id,
165 $this->
http->saveResponse(
166 $this->
http->response()->withBody(
174 $stream = $this->irss->consume()->stream($resource_id)->setRevisionNumber(
175 $current_revision->getVersionNumber()
177 $this->
http->saveResponse(
178 $this->
http->response()->withBody($stream)
185 if (!$is_file_convertion) {
186 throw new \InvalidArgumentException();
193 $body_stream = $this->
http->request()->getBody();
194 $body = $body_stream->getContents();
199 if ($this->saving_interval > 0) {
200 $latest_revision = $resource->getCurrentRevision();
201 $creation_time = $latest_revision->getInformation()->getCreationDate()->getTimestamp();
202 $current_time = time();
203 $time_diff = $current_time - $creation_time;
204 if ($time_diff > $this->saving_interval) {
205 $this->irss->manage()->publish($resource_id);
209 $new_revision = $this->irss->manage()->appendNewRevisionFromStream(
213 $current_revision->getTitle(),
222 $this->
http->saveResponse(
223 $this->
http->response()->withBody(
236 $this->
http->saveResponse(
237 $this->
http->response()->withBody(
245 $lock = $this->
http->request()->getHeader(self::HEADER_X_WOPI_LOCK)[0] ??
null;
246 $this->
http->saveResponse(
247 $this->
http->response()->withBody(
258 static fn(array $trace):
string => $trace[
'file'] .
':' . $trace[
'line'],
262 $message .=
"\n" . implode(
"\n", $trace);
264 $this->
http->saveResponse(
265 $this->
http->response()
268 ->withHeader(
'X-WOPI-ServerError', $t->getMessage())
271 $this->
http->sendResponse();
272 $this->
http->close();
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static http()
Fetches the global http state from ILIAS.
static ofString(string $string)
Creates a new stream with an initial value.