summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@users.noreply.github.com>2021-03-03 21:57:34 +0100
committerGitHub <noreply@github.com>2021-03-03 21:57:34 +0100
commit5325c3002cb45b6b244d0df7c74ea5a8bbb6ee02 (patch)
treedba66ff928b43e9fc240943395e0b5a3ae74c04c /lib
parenta58b4ceaabf88aea83c24a5555e8addb28634ded (diff)
parentcc744740b790a72e2d5c6b07814dadb5b58014fb (diff)
downloadnextcloud-server-5325c3002cb45b6b244d0df7c74ea5a8bbb6ee02.tar.gz
nextcloud-server-5325c3002cb45b6b244d0df7c74ea5a8bbb6ee02.zip
Merge pull request #25917 from nextcloud/techdept/kill_deprecated/ocp_api
Remove deprecated \OCP\API
Diffstat (limited to 'lib')
-rw-r--r--lib/composer/composer/autoload_classmap.php1
-rw-r--r--lib/composer/composer/autoload_static.php1
-rw-r--r--lib/private/AppFramework/Middleware/OCSMiddleware.php5
-rw-r--r--lib/private/AppFramework/OCS/V1Response.php4
-rw-r--r--lib/private/AppFramework/OCS/V2Response.php8
-rw-r--r--lib/private/Remote/Api/OCS.php6
-rw-r--r--lib/private/legacy/OC_API.php10
-rw-r--r--lib/public/API.php52
-rw-r--r--lib/public/AppFramework/OCSController.php4
9 files changed, 20 insertions, 71 deletions
diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php
index 621aa598b61..4f03731fe59 100644
--- a/lib/composer/composer/autoload_classmap.php
+++ b/lib/composer/composer/autoload_classmap.php
@@ -7,7 +7,6 @@ $baseDir = dirname(dirname($vendorDir));
return array(
'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
- 'OCP\\API' => $baseDir . '/lib/public/API.php',
'OCP\\Accounts\\IAccount' => $baseDir . '/lib/public/Accounts/IAccount.php',
'OCP\\Accounts\\IAccountManager' => $baseDir . '/lib/public/Accounts/IAccountManager.php',
'OCP\\Accounts\\IAccountProperty' => $baseDir . '/lib/public/Accounts/IAccountProperty.php',
diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php
index 68df3a21442..87f7f54622c 100644
--- a/lib/composer/composer/autoload_static.php
+++ b/lib/composer/composer/autoload_static.php
@@ -36,7 +36,6 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
public static $classMap = array (
'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
- 'OCP\\API' => __DIR__ . '/../../..' . '/lib/public/API.php',
'OCP\\Accounts\\IAccount' => __DIR__ . '/../../..' . '/lib/public/Accounts/IAccount.php',
'OCP\\Accounts\\IAccountManager' => __DIR__ . '/../../..' . '/lib/public/Accounts/IAccountManager.php',
'OCP\\Accounts\\IAccountProperty' => __DIR__ . '/../../..' . '/lib/public/Accounts/IAccountProperty.php',
diff --git a/lib/private/AppFramework/Middleware/OCSMiddleware.php b/lib/private/AppFramework/Middleware/OCSMiddleware.php
index 5016fc3eec8..f701f17a48e 100644
--- a/lib/private/AppFramework/Middleware/OCSMiddleware.php
+++ b/lib/private/AppFramework/Middleware/OCSMiddleware.php
@@ -29,7 +29,6 @@ use OC\AppFramework\Http;
use OC\AppFramework\OCS\BaseResponse;
use OC\AppFramework\OCS\V1Response;
use OC\AppFramework\OCS\V2Response;
-use OCP\API;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\Http\JSONResponse;
@@ -80,7 +79,7 @@ class OCSMiddleware extends Middleware {
if ($controller instanceof OCSController && $exception instanceof OCSException) {
$code = $exception->getCode();
if ($code === 0) {
- $code = API::RESPOND_UNKNOWN_ERROR;
+ $code = \OCP\AppFramework\OCSController::RESPOND_UNKNOWN_ERROR;
}
return $this->buildNewResponse($controller, $code, $exception->getMessage());
@@ -109,7 +108,7 @@ class OCSMiddleware extends Middleware {
$message = $response->getData()['message'];
}
- return $this->buildNewResponse($controller, API::RESPOND_UNAUTHORISED, $message);
+ return $this->buildNewResponse($controller, OCSController::RESPOND_UNAUTHORISED, $message);
}
}
diff --git a/lib/private/AppFramework/OCS/V1Response.php b/lib/private/AppFramework/OCS/V1Response.php
index 97a3acce681..9ccff9ac98c 100644
--- a/lib/private/AppFramework/OCS/V1Response.php
+++ b/lib/private/AppFramework/OCS/V1Response.php
@@ -24,8 +24,8 @@
namespace OC\AppFramework\OCS;
-use OCP\API;
use OCP\AppFramework\Http;
+use OCP\AppFramework\OCSController;
class V1Response extends BaseResponse {
@@ -37,7 +37,7 @@ class V1Response extends BaseResponse {
*/
public function getStatus() {
$status = parent::getStatus();
- if ($status === Http::STATUS_FORBIDDEN || $status === API::RESPOND_UNAUTHORISED) {
+ if ($status === Http::STATUS_FORBIDDEN || $status === OCSController::RESPOND_UNAUTHORISED) {
return Http::STATUS_UNAUTHORIZED;
}
diff --git a/lib/private/AppFramework/OCS/V2Response.php b/lib/private/AppFramework/OCS/V2Response.php
index 3d1868857ce..5a253adf676 100644
--- a/lib/private/AppFramework/OCS/V2Response.php
+++ b/lib/private/AppFramework/OCS/V2Response.php
@@ -24,8 +24,8 @@
namespace OC\AppFramework\OCS;
-use OCP\API;
use OCP\AppFramework\Http;
+use OCP\AppFramework\OCSController;
class V2Response extends BaseResponse {
@@ -37,11 +37,11 @@ class V2Response extends BaseResponse {
*/
public function getStatus() {
$status = parent::getStatus();
- if ($status === API::RESPOND_UNAUTHORISED) {
+ if ($status === OCSController::RESPOND_UNAUTHORISED) {
return Http::STATUS_UNAUTHORIZED;
- } elseif ($status === API::RESPOND_NOT_FOUND) {
+ } elseif ($status === OCSController::RESPOND_NOT_FOUND) {
return Http::STATUS_NOT_FOUND;
- } elseif ($status === API::RESPOND_SERVER_ERROR || $status === API::RESPOND_UNKNOWN_ERROR) {
+ } elseif ($status === OCSController::RESPOND_SERVER_ERROR || $status === OCSController::RESPOND_UNKNOWN_ERROR) {
return Http::STATUS_INTERNAL_SERVER_ERROR;
} elseif ($status < 200 || $status > 600) {
return Http::STATUS_BAD_REQUEST;
diff --git a/lib/private/Remote/Api/OCS.php b/lib/private/Remote/Api/OCS.php
index 770dce3545f..d6bed57f561 100644
--- a/lib/private/Remote/Api/OCS.php
+++ b/lib/private/Remote/Api/OCS.php
@@ -27,7 +27,7 @@ namespace OC\Remote\Api;
use GuzzleHttp\Exception\ClientException;
use OC\ForbiddenException;
use OC\Remote\User;
-use OCP\API;
+use OCP\AppFramework\OCSController;
use OCP\Remote\Api\ICapabilitiesApi;
use OCP\Remote\Api\IUserApi;
@@ -58,10 +58,10 @@ class OCS extends ApiBase implements ICapabilitiesApi, IUserApi {
if (!isset($response['ocs']) || !isset($response['ocs']['meta'])) {
throw new \Exception('Invalid ocs response');
}
- if ($response['ocs']['meta']['statuscode'] === API::RESPOND_UNAUTHORISED) {
+ if ($response['ocs']['meta']['statuscode'] === OCSController::RESPOND_UNAUTHORISED) {
throw new ForbiddenException();
}
- if ($response['ocs']['meta']['statuscode'] === API::RESPOND_NOT_FOUND) {
+ if ($response['ocs']['meta']['statuscode'] === OCSController::RESPOND_NOT_FOUND) {
throw new NotFoundException();
}
if ($response['ocs']['meta']['status'] !== 'ok') {
diff --git a/lib/private/legacy/OC_API.php b/lib/private/legacy/OC_API.php
index 16a144269b3..9e9c28e2dba 100644
--- a/lib/private/legacy/OC_API.php
+++ b/lib/private/legacy/OC_API.php
@@ -48,7 +48,7 @@ class OC_API {
$request = \OC::$server->getRequest();
// Send 401 headers if unauthorised
- if ($result->getStatusCode() === API::RESPOND_UNAUTHORISED) {
+ if ($result->getStatusCode() === \OCP\AppFramework\OCSController::RESPOND_UNAUTHORISED) {
// If request comes from JS return dummy auth request
if ($request->getHeader('X-Requested-With') === 'XMLHttpRequest') {
header('WWW-Authenticate: DummyBasic realm="Authorisation Required"');
@@ -143,13 +143,13 @@ class OC_API {
*/
public static function mapStatusCodes($sc) {
switch ($sc) {
- case API::RESPOND_NOT_FOUND:
+ case \OCP\AppFramework\OCSController::RESPOND_NOT_FOUND:
return Http::STATUS_NOT_FOUND;
- case API::RESPOND_SERVER_ERROR:
+ case \OCP\AppFramework\OCSController::RESPOND_SERVER_ERROR:
return Http::STATUS_INTERNAL_SERVER_ERROR;
- case API::RESPOND_UNKNOWN_ERROR:
+ case \OCP\AppFramework\OCSController::RESPOND_UNKNOWN_ERROR:
return Http::STATUS_INTERNAL_SERVER_ERROR;
- case API::RESPOND_UNAUTHORISED:
+ case \OCP\AppFramework\OCSController::RESPOND_UNAUTHORISED:
// already handled for v1
return null;
case 100:
diff --git a/lib/public/API.php b/lib/public/API.php
deleted file mode 100644
index 65a0704d51c..00000000000
--- a/lib/public/API.php
+++ /dev/null
@@ -1,52 +0,0 @@
-<?php
-/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Joas Schilling <coding@schilljs.com>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- * @author Tom Needham <tom@owncloud.com>
- *
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
- */
-
-/**
- * Public interface of ownCloud for apps to use.
- * API Class
- *
- */
-
-// use OCP namespace for all classes that are considered public.
-// This means that they should be used by apps instead of the internal ownCloud classes
-
-namespace OCP;
-
-/**
- * This class provides functions to manage apps in ownCloud
- * @since 5.0.0
- * @deprecated 9.1.0 Use the AppFramework
- */
-class API {
- /**
- * API Response Codes
- * @since 8.1.0
- */
- public const RESPOND_UNAUTHORISED = 997;
- public const RESPOND_SERVER_ERROR = 996;
- public const RESPOND_NOT_FOUND = 998;
- public const RESPOND_UNKNOWN_ERROR = 999;
-}
diff --git a/lib/public/AppFramework/OCSController.php b/lib/public/AppFramework/OCSController.php
index d18ab04fae8..422195f6b24 100644
--- a/lib/public/AppFramework/OCSController.php
+++ b/lib/public/AppFramework/OCSController.php
@@ -42,6 +42,10 @@ use OCP\IRequest;
* @since 8.1.0
*/
abstract class OCSController extends ApiController {
+ public const RESPOND_UNAUTHORISED = 997;
+ public const RESPOND_SERVER_ERROR = 996;
+ public const RESPOND_NOT_FOUND = 998;
+ public const RESPOND_UNKNOWN_ERROR = 999;
/** @var int */
private $ocsVersion;