@@ -33,13 +33,13 @@ discard block |
||
33 | 33 | require_once __DIR__ . '/../lib/base.php'; |
34 | 34 | |
35 | 35 | if (\OCP\Util::needUpgrade() |
36 | - || \OC::$server->getConfig()->getSystemValueBool('maintenance')) { |
|
37 | - // since the behavior of apps or remotes are unpredictable during |
|
38 | - // an upgrade, return a 503 directly |
|
39 | - http_response_code(503); |
|
40 | - $response = new \OC\OCS\Result(null, 503, 'Service unavailable'); |
|
41 | - OC_API::respond($response, OC_API::requestedFormat()); |
|
42 | - exit; |
|
36 | + || \OC::$server->getConfig()->getSystemValueBool('maintenance')) { |
|
37 | + // since the behavior of apps or remotes are unpredictable during |
|
38 | + // an upgrade, return a 503 directly |
|
39 | + http_response_code(503); |
|
40 | + $response = new \OC\OCS\Result(null, 503, 'Service unavailable'); |
|
41 | + OC_API::respond($response, OC_API::requestedFormat()); |
|
42 | + exit; |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | use Symfony\Component\Routing\Exception\ResourceNotFoundException; |
@@ -50,62 +50,62 @@ discard block |
||
50 | 50 | * We first try the old routes since the appframework triggers more login stuff. |
51 | 51 | */ |
52 | 52 | try { |
53 | - OC_App::loadApps(['session']); |
|
54 | - OC_App::loadApps(['authentication']); |
|
55 | - // load all apps to get all api routes properly setup |
|
56 | - OC_App::loadApps(); |
|
53 | + OC_App::loadApps(['session']); |
|
54 | + OC_App::loadApps(['authentication']); |
|
55 | + // load all apps to get all api routes properly setup |
|
56 | + OC_App::loadApps(); |
|
57 | 57 | |
58 | - OC::$server->getRouter()->match('/ocs'.\OC::$server->getRequest()->getRawPathInfo()); |
|
58 | + OC::$server->getRouter()->match('/ocs'.\OC::$server->getRequest()->getRawPathInfo()); |
|
59 | 59 | |
60 | - sleep(1); |
|
61 | - OC::$server->getLogger()->info('This uses an old OCP\API::register construct. This will be removed in a future version of Nextcloud. Please migrate to the OCSController'); |
|
60 | + sleep(1); |
|
61 | + OC::$server->getLogger()->info('This uses an old OCP\API::register construct. This will be removed in a future version of Nextcloud. Please migrate to the OCSController'); |
|
62 | 62 | |
63 | - return; |
|
63 | + return; |
|
64 | 64 | } catch (ResourceNotFoundException $e) { |
65 | - // Fall through the not found |
|
65 | + // Fall through the not found |
|
66 | 66 | } catch (MethodNotAllowedException $e) { |
67 | - OC_API::setContentType(); |
|
68 | - http_response_code(405); |
|
69 | - exit(); |
|
67 | + OC_API::setContentType(); |
|
68 | + http_response_code(405); |
|
69 | + exit(); |
|
70 | 70 | } catch (\OC\OCS\Exception $ex) { |
71 | - OC_API::respond($ex->getResult(), OC_API::requestedFormat()); |
|
72 | - exit(); |
|
71 | + OC_API::respond($ex->getResult(), OC_API::requestedFormat()); |
|
72 | + exit(); |
|
73 | 73 | } catch (Throwable $ex) { |
74 | - OC::$server->getLogger()->logException($ex); |
|
74 | + OC::$server->getLogger()->logException($ex); |
|
75 | 75 | |
76 | - OC_API::setContentType(); |
|
77 | - http_response_code(500); |
|
78 | - exit(); |
|
76 | + OC_API::setContentType(); |
|
77 | + http_response_code(500); |
|
78 | + exit(); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /* |
82 | 82 | * Try the appframework routes |
83 | 83 | */ |
84 | 84 | try { |
85 | - if (!\OC::$server->getUserSession()->isLoggedIn()) { |
|
86 | - OC::handleLogin(\OC::$server->getRequest()); |
|
87 | - } |
|
88 | - OC::$server->getRouter()->match('/ocsapp'.\OC::$server->getRequest()->getRawPathInfo()); |
|
85 | + if (!\OC::$server->getUserSession()->isLoggedIn()) { |
|
86 | + OC::handleLogin(\OC::$server->getRequest()); |
|
87 | + } |
|
88 | + OC::$server->getRouter()->match('/ocsapp'.\OC::$server->getRequest()->getRawPathInfo()); |
|
89 | 89 | } catch (ResourceNotFoundException $e) { |
90 | - OC_API::setContentType(); |
|
90 | + OC_API::setContentType(); |
|
91 | 91 | |
92 | - $format = \OC::$server->getRequest()->getParam('format', 'xml'); |
|
93 | - $txt='Invalid query, please check the syntax. API specifications are here:' |
|
94 | - .' http://www.freedesktop.org/wiki/Specifications/open-collaboration-services.'."\n"; |
|
95 | - OC_API::respond(new \OC\OCS\Result(null, \OCP\API::RESPOND_NOT_FOUND, $txt), $format); |
|
92 | + $format = \OC::$server->getRequest()->getParam('format', 'xml'); |
|
93 | + $txt='Invalid query, please check the syntax. API specifications are here:' |
|
94 | + .' http://www.freedesktop.org/wiki/Specifications/open-collaboration-services.'."\n"; |
|
95 | + OC_API::respond(new \OC\OCS\Result(null, \OCP\API::RESPOND_NOT_FOUND, $txt), $format); |
|
96 | 96 | } catch (MethodNotAllowedException $e) { |
97 | - OC_API::setContentType(); |
|
98 | - http_response_code(405); |
|
97 | + OC_API::setContentType(); |
|
98 | + http_response_code(405); |
|
99 | 99 | } catch (\OC\OCS\Exception $ex) { |
100 | - OC_API::respond($ex->getResult(), OC_API::requestedFormat()); |
|
100 | + OC_API::respond($ex->getResult(), OC_API::requestedFormat()); |
|
101 | 101 | } catch (\OC\User\LoginException $e) { |
102 | - OC_API::respond(new \OC\OCS\Result(null, \OCP\API::RESPOND_UNAUTHORISED, 'Unauthorised')); |
|
102 | + OC_API::respond(new \OC\OCS\Result(null, \OCP\API::RESPOND_UNAUTHORISED, 'Unauthorised')); |
|
103 | 103 | } catch (\Exception $e) { |
104 | - \OC::$server->getLogger()->logException($e); |
|
105 | - OC_API::setContentType(); |
|
104 | + \OC::$server->getLogger()->logException($e); |
|
105 | + OC_API::setContentType(); |
|
106 | 106 | |
107 | - $format = \OC::$server->getRequest()->getParam('format', 'xml'); |
|
108 | - $txt='Invalid query, please check the syntax. API specifications are here:' |
|
109 | - .' http://www.freedesktop.org/wiki/Specifications/open-collaboration-services.'."\n"; |
|
110 | - OC_API::respond(new \OC\OCS\Result(null, \OCP\API::RESPOND_NOT_FOUND, $txt), $format); |
|
107 | + $format = \OC::$server->getRequest()->getParam('format', 'xml'); |
|
108 | + $txt='Invalid query, please check the syntax. API specifications are here:' |
|
109 | + .' http://www.freedesktop.org/wiki/Specifications/open-collaboration-services.'."\n"; |
|
110 | + OC_API::respond(new \OC\OCS\Result(null, \OCP\API::RESPOND_NOT_FOUND, $txt), $format); |
|
111 | 111 | } |