Merge pull request #6605 from nextcloud/oc_ocs_response_is_dep
OC_OCS_Response is deprecated
This commit is contained in:
commit
38568c362b
|
@ -72,7 +72,7 @@ class Api {
|
||||||
* Returns the mount points visible for this user.
|
* Returns the mount points visible for this user.
|
||||||
*
|
*
|
||||||
* @param array $params
|
* @param array $params
|
||||||
* @return \OC_OCS_Result share information
|
* @return \OC\OCS\Result share information
|
||||||
*/
|
*/
|
||||||
public static function getUserMounts($params) {
|
public static function getUserMounts($params) {
|
||||||
$entries = array();
|
$entries = array();
|
||||||
|
@ -83,6 +83,6 @@ class Api {
|
||||||
$entries[] = self::formatMount($mountPoint, $mount);
|
$entries[] = self::formatMount($mountPoint, $mount);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new \OC_OCS_Result($entries);
|
return new \OC\OCS\Result($entries);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -220,7 +220,7 @@ class ShareAPIControllerTest extends TestCase {
|
||||||
->with('ocinternal:42')
|
->with('ocinternal:42')
|
||||||
->will($this->throwException(new \OC\Share20\Exception\ShareNotFound()));
|
->will($this->throwException(new \OC\Share20\Exception\ShareNotFound()));
|
||||||
|
|
||||||
$expected = new \OC_OCS_Result(null, 404, 'wrong share ID, share doesn\'t exist.');
|
$expected = new \OC\OCS\Result(null, 404, 'wrong share ID, share doesn\'t exist.');
|
||||||
$this->assertEquals($expected, $this->ocs->getShare(42));
|
$this->assertEquals($expected, $this->ocs->getShare(42));
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -129,7 +129,7 @@ class OC_API {
|
||||||
if(!self::isAuthorised($action)) {
|
if(!self::isAuthorised($action)) {
|
||||||
$responses[] = array(
|
$responses[] = array(
|
||||||
'app' => $action['app'],
|
'app' => $action['app'],
|
||||||
'response' => new OC_OCS_Result(null, API::RESPOND_UNAUTHORISED, 'Unauthorised'),
|
'response' => new \OC\OCS\Result(null, API::RESPOND_UNAUTHORISED, 'Unauthorised'),
|
||||||
'shipped' => $appManager->isShipped($action['app']),
|
'shipped' => $appManager->isShipped($action['app']),
|
||||||
);
|
);
|
||||||
continue;
|
continue;
|
||||||
|
@ -137,7 +137,7 @@ class OC_API {
|
||||||
if(!is_callable($action['action'])) {
|
if(!is_callable($action['action'])) {
|
||||||
$responses[] = array(
|
$responses[] = array(
|
||||||
'app' => $action['app'],
|
'app' => $action['app'],
|
||||||
'response' => new OC_OCS_Result(null, API::RESPOND_NOT_FOUND, 'Api method not found'),
|
'response' => new \OC\OCS\Result(null, API::RESPOND_NOT_FOUND, 'Api method not found'),
|
||||||
'shipped' => $appManager->isShipped($action['app']),
|
'shipped' => $appManager->isShipped($action['app']),
|
||||||
);
|
);
|
||||||
continue;
|
continue;
|
||||||
|
@ -161,7 +161,7 @@ class OC_API {
|
||||||
/**
|
/**
|
||||||
* merge the returned result objects into one response
|
* merge the returned result objects into one response
|
||||||
* @param array $responses
|
* @param array $responses
|
||||||
* @return OC_OCS_Result
|
* @return \OC\OCS\Result
|
||||||
*/
|
*/
|
||||||
public static function mergeResponses($responses) {
|
public static function mergeResponses($responses) {
|
||||||
// Sort into shipped and third-party
|
// Sort into shipped and third-party
|
||||||
|
@ -205,7 +205,7 @@ class OC_API {
|
||||||
$code = $picked['response']->getStatusCode();
|
$code = $picked['response']->getStatusCode();
|
||||||
$meta = $picked['response']->getMeta();
|
$meta = $picked['response']->getMeta();
|
||||||
$headers = $picked['response']->getHeaders();
|
$headers = $picked['response']->getHeaders();
|
||||||
$response = new OC_OCS_Result($data, $code, $meta['message'], $headers);
|
$response = new \OC\OCS\Result($data, $code, $meta['message'], $headers);
|
||||||
return $response;
|
return $response;
|
||||||
} elseif(!empty($shipped['succeeded'])) {
|
} elseif(!empty($shipped['succeeded'])) {
|
||||||
$responses = array_merge($shipped['succeeded'], $thirdparty['succeeded']);
|
$responses = array_merge($shipped['succeeded'], $thirdparty['succeeded']);
|
||||||
|
@ -219,7 +219,7 @@ class OC_API {
|
||||||
$code = $picked['response']->getStatusCode();
|
$code = $picked['response']->getStatusCode();
|
||||||
$meta = $picked['response']->getMeta();
|
$meta = $picked['response']->getMeta();
|
||||||
$headers = $picked['response']->getHeaders();
|
$headers = $picked['response']->getHeaders();
|
||||||
$response = new OC_OCS_Result($data, $code, $meta['message'], $headers);
|
$response = new \OC\OCS\Result($data, $code, $meta['message'], $headers);
|
||||||
return $response;
|
return $response;
|
||||||
} else {
|
} else {
|
||||||
$responses = $thirdparty['succeeded'];
|
$responses = $thirdparty['succeeded'];
|
||||||
|
@ -251,7 +251,7 @@ class OC_API {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new OC_OCS_Result($data, $statusCode, $statusMessage, $header);
|
return new \OC\OCS\Result($data, $statusCode, $statusMessage, $header);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -351,7 +351,7 @@ class OC_API {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* respond to a call
|
* respond to a call
|
||||||
* @param OC_OCS_Result $result
|
* @param \OC\OCS\Result $result
|
||||||
* @param string $format the format xml|json
|
* @param string $format the format xml|json
|
||||||
*/
|
*/
|
||||||
public static function respond($result, $format='xml') {
|
public static function respond($result, $format='xml') {
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
<?php
|
|
||||||
/**
|
|
||||||
* @copyright Copyright (c) 2016, ownCloud, Inc.
|
|
||||||
*
|
|
||||||
* @author Roeland Jago Douma <roeland@famdouma.nl>
|
|
||||||
* @author Thomas Müller <thomas.mueller@tmit.eu>
|
|
||||||
*
|
|
||||||
* @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/>
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Since 9.1.0 use \OC\OCS\Result
|
|
||||||
*/
|
|
||||||
class OC_OCS_Result extends \OC\OCS\Result {
|
|
||||||
}
|
|
|
@ -83,7 +83,7 @@ class OCSResponse extends Response {
|
||||||
* @suppress PhanDeprecatedClass
|
* @suppress PhanDeprecatedClass
|
||||||
*/
|
*/
|
||||||
public function render() {
|
public function render() {
|
||||||
$r = new \OC_OCS_Result($this->data, $this->statuscode, $this->message);
|
$r = new \OC\OCS\Result($this->data, $this->statuscode, $this->message);
|
||||||
$r->setTotalItems($this->itemscount);
|
$r->setTotalItems($this->itemscount);
|
||||||
$r->setItemsPerPage($this->itemsperpage);
|
$r->setItemsPerPage($this->itemsperpage);
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ if (\OCP\Util::needUpgrade()
|
||||||
// since the behavior of apps or remotes are unpredictable during
|
// since the behavior of apps or remotes are unpredictable during
|
||||||
// an upgrade, return a 503 directly
|
// an upgrade, return a 503 directly
|
||||||
OC_Response::setStatus(OC_Response::STATUS_SERVICE_UNAVAILABLE);
|
OC_Response::setStatus(OC_Response::STATUS_SERVICE_UNAVAILABLE);
|
||||||
$response = new OC_OCS_Result(null, OC_Response::STATUS_SERVICE_UNAVAILABLE, 'Service unavailable');
|
$response = new \OC\OCS\Result(null, OC_Response::STATUS_SERVICE_UNAVAILABLE, 'Service unavailable');
|
||||||
OC_API::respond($response, OC_API::requestedFormat());
|
OC_API::respond($response, OC_API::requestedFormat());
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
@ -81,14 +81,14 @@ try {
|
||||||
$format = \OC::$server->getRequest()->getParam('format', 'xml');
|
$format = \OC::$server->getRequest()->getParam('format', 'xml');
|
||||||
$txt='Invalid query, please check the syntax. API specifications are here:'
|
$txt='Invalid query, please check the syntax. API specifications are here:'
|
||||||
.' http://www.freedesktop.org/wiki/Specifications/open-collaboration-services. DEBUG OUTPUT:'."\n";
|
.' http://www.freedesktop.org/wiki/Specifications/open-collaboration-services. DEBUG OUTPUT:'."\n";
|
||||||
OC_API::respond(new OC_OCS_Result(null, \OCP\API::RESPOND_NOT_FOUND, $txt), $format);
|
OC_API::respond(new \OC\OCS\Result(null, \OCP\API::RESPOND_NOT_FOUND, $txt), $format);
|
||||||
} catch (MethodNotAllowedException $e) {
|
} catch (MethodNotAllowedException $e) {
|
||||||
OC_API::setContentType();
|
OC_API::setContentType();
|
||||||
OC_Response::setStatus(405);
|
OC_Response::setStatus(405);
|
||||||
} catch (\OC\OCS\Exception $ex) {
|
} catch (\OC\OCS\Exception $ex) {
|
||||||
OC_API::respond($ex->getResult(), OC_API::requestedFormat());
|
OC_API::respond($ex->getResult(), OC_API::requestedFormat());
|
||||||
} catch (\OC\User\LoginException $e) {
|
} catch (\OC\User\LoginException $e) {
|
||||||
OC_API::respond(new OC_OCS_Result(null, \OCP\API::RESPOND_UNAUTHORISED, 'Unauthorised'));
|
OC_API::respond(new \OC\OCS\Result(null, \OCP\API::RESPOND_UNAUTHORISED, 'Unauthorised'));
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
\OC::$server->getLogger()->logException($e);
|
\OC::$server->getLogger()->logException($e);
|
||||||
OC_API::setContentType();
|
OC_API::setContentType();
|
||||||
|
@ -96,6 +96,6 @@ try {
|
||||||
$format = \OC::$server->getRequest()->getParam('format', 'xml');
|
$format = \OC::$server->getRequest()->getParam('format', 'xml');
|
||||||
$txt='Invalid query, please check the syntax. API specifications are here:'
|
$txt='Invalid query, please check the syntax. API specifications are here:'
|
||||||
.' http://www.freedesktop.org/wiki/Specifications/open-collaboration-services. DEBUG OUTPUT:'."\n";
|
.' http://www.freedesktop.org/wiki/Specifications/open-collaboration-services. DEBUG OUTPUT:'."\n";
|
||||||
OC_API::respond(new OC_OCS_Result(null, \OCP\API::RESPOND_NOT_FOUND, $txt), $format);
|
OC_API::respond(new \OC\OCS\Result(null, \OCP\API::RESPOND_NOT_FOUND, $txt), $format);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ class APITest extends \Test\TestCase {
|
||||||
* @param string $message
|
* @param string $message
|
||||||
*/
|
*/
|
||||||
function buildResponse($shipped, $data, $code, $message=null) {
|
function buildResponse($shipped, $data, $code, $message=null) {
|
||||||
$resp = new \OC_OCS_Result($data, $code, $message);
|
$resp = new \OC\OCS\Result($data, $code, $message);
|
||||||
$resp->addHeader('KEY', 'VALUE');
|
$resp->addHeader('KEY', 'VALUE');
|
||||||
return [
|
return [
|
||||||
'shipped' => $shipped,
|
'shipped' => $shipped,
|
||||||
|
@ -28,13 +28,13 @@ class APITest extends \Test\TestCase {
|
||||||
// Validate details of the result
|
// Validate details of the result
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \OC_OCS_Result $result
|
* @param \OC\OCS\Result $result
|
||||||
*/
|
*/
|
||||||
function checkResult($result, $success) {
|
function checkResult($result, $success) {
|
||||||
// Check response is of correct type
|
// Check response is of correct type
|
||||||
$this->assertInstanceOf('OC_OCS_Result', $result);
|
$this->assertInstanceOf(\OC\OCS\Result::class, $result);
|
||||||
// Check if it succeeded
|
// Check if it succeeded
|
||||||
/** @var $result \OC_OCS_Result */
|
/** @var $result \OC\OCS\Result */
|
||||||
$this->assertEquals($success, $result->succeeded());
|
$this->assertEquals($success, $result->succeeded());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue