mirror of
https://github.com/nextcloud/server.git
synced 2026-02-20 16:35:37 -05:00
fix: Move OC_API into \OC\ApiHelper in standard namespace
It’s only used by ocs/v1.php Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
This commit is contained in:
parent
1fa674d907
commit
ea32d17d88
4 changed files with 17 additions and 12 deletions
|
|
@ -956,6 +956,7 @@ return array(
|
|||
'OC\\AppFramework\\Middleware\\Security\\SameSiteCookieMiddleware' => $baseDir . '/lib/private/AppFramework/Middleware/Security/SameSiteCookieMiddleware.php',
|
||||
'OC\\AppFramework\\Middleware\\Security\\SecurityMiddleware' => $baseDir . '/lib/private/AppFramework/Middleware/Security/SecurityMiddleware.php',
|
||||
'OC\\AppFramework\\Middleware\\SessionMiddleware' => $baseDir . '/lib/private/AppFramework/Middleware/SessionMiddleware.php',
|
||||
'OC\\AppFramework\\OCS\\ApiHelper' => $baseDir . '/lib/private/AppFramework/OCS/ApiHelper.php',
|
||||
'OC\\AppFramework\\OCS\\BaseResponse' => $baseDir . '/lib/private/AppFramework/OCS/BaseResponse.php',
|
||||
'OC\\AppFramework\\OCS\\V1Response' => $baseDir . '/lib/private/AppFramework/OCS/V1Response.php',
|
||||
'OC\\AppFramework\\OCS\\V2Response' => $baseDir . '/lib/private/AppFramework/OCS/V2Response.php',
|
||||
|
|
@ -2000,7 +2001,6 @@ return array(
|
|||
'OC\\User\\OutOfOfficeData' => $baseDir . '/lib/private/User/OutOfOfficeData.php',
|
||||
'OC\\User\\Session' => $baseDir . '/lib/private/User/Session.php',
|
||||
'OC\\User\\User' => $baseDir . '/lib/private/User/User.php',
|
||||
'OC_API' => $baseDir . '/lib/private/legacy/OC_API.php',
|
||||
'OC_App' => $baseDir . '/lib/private/legacy/OC_App.php',
|
||||
'OC_Defaults' => $baseDir . '/lib/private/legacy/OC_Defaults.php',
|
||||
'OC_Files' => $baseDir . '/lib/private/legacy/OC_Files.php',
|
||||
|
|
|
|||
|
|
@ -989,6 +989,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
|
|||
'OC\\AppFramework\\Middleware\\Security\\SameSiteCookieMiddleware' => __DIR__ . '/../../..' . '/lib/private/AppFramework/Middleware/Security/SameSiteCookieMiddleware.php',
|
||||
'OC\\AppFramework\\Middleware\\Security\\SecurityMiddleware' => __DIR__ . '/../../..' . '/lib/private/AppFramework/Middleware/Security/SecurityMiddleware.php',
|
||||
'OC\\AppFramework\\Middleware\\SessionMiddleware' => __DIR__ . '/../../..' . '/lib/private/AppFramework/Middleware/SessionMiddleware.php',
|
||||
'OC\\AppFramework\\OCS\\ApiHelper' => __DIR__ . '/../../..' . '/lib/private/AppFramework/OCS/ApiHelper.php',
|
||||
'OC\\AppFramework\\OCS\\BaseResponse' => __DIR__ . '/../../..' . '/lib/private/AppFramework/OCS/BaseResponse.php',
|
||||
'OC\\AppFramework\\OCS\\V1Response' => __DIR__ . '/../../..' . '/lib/private/AppFramework/OCS/V1Response.php',
|
||||
'OC\\AppFramework\\OCS\\V2Response' => __DIR__ . '/../../..' . '/lib/private/AppFramework/OCS/V2Response.php',
|
||||
|
|
@ -2033,7 +2034,6 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
|
|||
'OC\\User\\OutOfOfficeData' => __DIR__ . '/../../..' . '/lib/private/User/OutOfOfficeData.php',
|
||||
'OC\\User\\Session' => __DIR__ . '/../../..' . '/lib/private/User/Session.php',
|
||||
'OC\\User\\User' => __DIR__ . '/../../..' . '/lib/private/User/User.php',
|
||||
'OC_API' => __DIR__ . '/../../..' . '/lib/private/legacy/OC_API.php',
|
||||
'OC_App' => __DIR__ . '/../../..' . '/lib/private/legacy/OC_App.php',
|
||||
'OC_Defaults' => __DIR__ . '/../../..' . '/lib/private/legacy/OC_Defaults.php',
|
||||
'OC_Files' => __DIR__ . '/../../..' . '/lib/private/legacy/OC_Files.php',
|
||||
|
|
|
|||
|
|
@ -5,10 +5,13 @@
|
|||
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
namespace OC\AppFramework\OCS;
|
||||
|
||||
use OCP\API;
|
||||
use OCP\AppFramework\Http;
|
||||
|
||||
class OC_API {
|
||||
class ApiHelper {
|
||||
/**
|
||||
* api actions
|
||||
*/
|
||||
20
ocs/v1.php
20
ocs/v1.php
|
|
@ -7,6 +7,8 @@
|
|||
require_once __DIR__ . '/../lib/versioncheck.php';
|
||||
require_once __DIR__ . '/../lib/base.php';
|
||||
|
||||
use OC\AppFramework\OCS\ApiHelper;
|
||||
|
||||
if (\OCP\Util::needUpgrade()
|
||||
|| \OC::$server->getConfig()->getSystemValueBool('maintenance')) {
|
||||
// since the behavior of apps or remotes are unpredictable during
|
||||
|
|
@ -14,7 +16,7 @@ if (\OCP\Util::needUpgrade()
|
|||
http_response_code(503);
|
||||
header('X-Nextcloud-Maintenance-Mode: 1');
|
||||
$response = new \OC\OCS\Result(null, 503, 'Service unavailable');
|
||||
OC_API::respond($response, OC_API::requestedFormat());
|
||||
ApiHelper::respond($response, ApiHelper::requestedFormat());
|
||||
exit;
|
||||
}
|
||||
|
||||
|
|
@ -43,24 +45,24 @@ try {
|
|||
OC::$server->get(\OC\Route\Router::class)->match('/ocsapp'.\OC::$server->getRequest()->getRawPathInfo());
|
||||
} catch (MaxDelayReached $ex) {
|
||||
$format = \OC::$server->getRequest()->getParam('format', 'xml');
|
||||
OC_API::respond(new \OC\OCS\Result(null, OCP\AppFramework\Http::STATUS_TOO_MANY_REQUESTS, $ex->getMessage()), $format);
|
||||
ApiHelper::respond(new \OC\OCS\Result(null, OCP\AppFramework\Http::STATUS_TOO_MANY_REQUESTS, $ex->getMessage()), $format);
|
||||
} catch (ResourceNotFoundException $e) {
|
||||
OC_API::setContentType();
|
||||
ApiHelper::setContentType();
|
||||
|
||||
$format = \OC::$server->getRequest()->getParam('format', 'xml');
|
||||
$txt = 'Invalid query, please check the syntax. API specifications are here:'
|
||||
.' http://www.freedesktop.org/wiki/Specifications/open-collaboration-services.'."\n";
|
||||
OC_API::respond(new \OC\OCS\Result(null, \OCP\AppFramework\OCSController::RESPOND_NOT_FOUND, $txt), $format);
|
||||
ApiHelper::respond(new \OC\OCS\Result(null, \OCP\AppFramework\OCSController::RESPOND_NOT_FOUND, $txt), $format);
|
||||
} catch (MethodNotAllowedException $e) {
|
||||
OC_API::setContentType();
|
||||
ApiHelper::setContentType();
|
||||
http_response_code(405);
|
||||
} catch (\OC\OCS\Exception $ex) {
|
||||
OC_API::respond($ex->getResult(), OC_API::requestedFormat());
|
||||
ApiHelper::respond($ex->getResult(), ApiHelper::requestedFormat());
|
||||
} catch (\OC\User\LoginException $e) {
|
||||
OC_API::respond(new \OC\OCS\Result(null, \OCP\AppFramework\OCSController::RESPOND_UNAUTHORISED, 'Unauthorised'));
|
||||
ApiHelper::respond(new \OC\OCS\Result(null, \OCP\AppFramework\OCSController::RESPOND_UNAUTHORISED, 'Unauthorised'));
|
||||
} catch (\Exception $e) {
|
||||
\OCP\Server::get(LoggerInterface::class)->error($e->getMessage(), ['exception' => $e]);
|
||||
OC_API::setContentType();
|
||||
ApiHelper::setContentType();
|
||||
|
||||
$format = \OC::$server->getRequest()->getParam('format', 'xml');
|
||||
$txt = 'Internal Server Error'."\n";
|
||||
|
|
@ -71,5 +73,5 @@ try {
|
|||
} catch (\Throwable $e) {
|
||||
// Just to be save
|
||||
}
|
||||
OC_API::respond(new \OC\OCS\Result(null, \OCP\AppFramework\OCSController::RESPOND_SERVER_ERROR, $txt), $format);
|
||||
ApiHelper::respond(new \OC\OCS\Result(null, \OCP\AppFramework\OCSController::RESPOND_SERVER_ERROR, $txt), $format);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue