diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2015-08-03 18:06:07 +0200 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2015-08-03 18:06:07 +0200 |
commit | 3358db320b0c159df6012bd65243b0b970be4fae (patch) | |
tree | 182df2212ab621d9171b860cc2e7845670c73c13 /lib/private/ocs.php | |
parent | bacf1603ffd53b7a5f73854d1d0ceb4ae545ce9f (diff) | |
download | nextcloud-server-3358db320b0c159df6012bd65243b0b970be4fae.tar.gz nextcloud-server-3358db320b0c159df6012bd65243b0b970be4fae.zip |
Reduce duplicate code
Diffstat (limited to 'lib/private/ocs.php')
-rw-r--r-- | lib/private/ocs.php | 19 |
1 files changed, 4 insertions, 15 deletions
diff --git a/lib/private/ocs.php b/lib/private/ocs.php index 6d166f8adb0..1b5ec2f35ac 100644 --- a/lib/private/ocs.php +++ b/lib/private/ocs.php @@ -28,6 +28,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/> * */ +use OCP\API; /** * Class to handle open collaboration services API requests @@ -64,8 +65,7 @@ class OC_OCS { } } if ($data === false) { - echo self::generateXml('', 'fail', 400, 'Bad request. Please provide a valid '.$key); - exit(); + throw new \OC\OCS\Exception(new OC_OCS_Result(null, 400, 'Bad request. Please provide a valid '.$key)); } else { // NOTE: Is the raw type necessary? It might be a little risky without sanitization if ($type == 'raw') return $data; @@ -78,23 +78,12 @@ class OC_OCS { } public static function notFound() { - if($_SERVER['REQUEST_METHOD'] == 'GET') { - $method='get'; - }elseif($_SERVER['REQUEST_METHOD'] == 'PUT') { - $method='put'; - }elseif($_SERVER['REQUEST_METHOD'] == 'POST') { - $method='post'; - }else{ - echo('internal server error: method not supported'); - exit(); - } - - $format = self::readData($method, 'format', 'text', ''); + $format = OC_API::requestedFormat(); $txt='Invalid query, please check the syntax. API specifications are here:' .' http://www.freedesktop.org/wiki/Specifications/open-collaboration-services. DEBUG OUTPUT:'."\n"; $txt.=OC_OCS::getDebugOutput(); - echo(OC_OCS::generateXml($format, 'failed', 999, $txt)); + OC_API::respond(new OC_OCS_Result(null, API::RESPOND_UNKNOWN_ERROR, $txt), $format); } /** |