|
|
|
@ -34,7 +34,6 @@
|
|
|
|
|
* @source: http://www.webodf.org/
|
|
|
|
|
* @source: http://gitorious.org/webodf/webodf/
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
// OCP\JSON::checkLoggedIn();
|
|
|
|
|
// OCP\JSON::checkAppEnabled('office');
|
|
|
|
|
// session_write_close();
|
|
|
|
@ -50,9 +49,9 @@ function bogusSession($i){
|
|
|
|
|
return $bs;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try{
|
|
|
|
|
$request = new OCA\Office\Request();
|
|
|
|
|
$command = $request->getParam('command');
|
|
|
|
|
|
|
|
|
|
$response = array();
|
|
|
|
|
switch ($command){
|
|
|
|
|
case 'session-list':
|
|
|
|
@ -76,7 +75,11 @@ switch ($command){
|
|
|
|
|
if ($seqHead > $currentHead){
|
|
|
|
|
foreach ($ops as $op){
|
|
|
|
|
$op['opspec'] = json_encode($op['opspec']);
|
|
|
|
|
try{
|
|
|
|
|
OCA\Office\Op::add($op);
|
|
|
|
|
} catch (Exception $e){
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// result: 'conflict',
|
|
|
|
@ -87,32 +90,37 @@ switch ($command){
|
|
|
|
|
$last = end($response["ops"]);
|
|
|
|
|
$response["headSeq"] = $last['seq'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
// Error :)
|
|
|
|
|
// Error - empty seq_head passed :)
|
|
|
|
|
throw new BadRequestException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* try {
|
|
|
|
|
* OCA\Office\Op::add(
|
|
|
|
|
* array(
|
|
|
|
|
* 'es_id' => ES_ID,
|
|
|
|
|
* 'seq' => SEQ,
|
|
|
|
|
* 'member' => MEMBER,
|
|
|
|
|
* 'opspec' => OPSPEC
|
|
|
|
|
* )
|
|
|
|
|
* );
|
|
|
|
|
* } catch (Exception $e) {
|
|
|
|
|
*
|
|
|
|
|
* }
|
|
|
|
|
*/
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
$ex = new BadRequestException();
|
|
|
|
|
$ex->setBody("{err:'bad request: [" . $request->getRawRequest() . "]'}");
|
|
|
|
|
throw $ex;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
\OCP\JSON::success($response);
|
|
|
|
|
} catch (BadRequestException $e){
|
|
|
|
|
header('HTTP/1.1 400: BAD REQUEST');
|
|
|
|
|
print("");
|
|
|
|
|
print("{err:'bad request: [$postbody]'}");
|
|
|
|
|
print($e->getBody());
|
|
|
|
|
print("");
|
|
|
|
|
}
|
|
|
|
|
exit();
|
|
|
|
|
|
|
|
|
|
class BadRequestException extends Exception {
|
|
|
|
|
|
|
|
|
|
protected $body = "";
|
|
|
|
|
|
|
|
|
|
public function setBody($body){
|
|
|
|
|
$this->body = $body;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
\OCP\JSON::success($response);
|
|
|
|
|
public function getBody(){
|
|
|
|
|
return $this->body;
|
|
|
|
|
}
|
|
|
|
|
}
|