/**
     main function to handle the REST request
   **/
 public static function handle()
 {
     // overwrite the 404 error page returncode
     header("HTTP/1.0 200 OK");
     if ($_SERVER['REQUEST_METHOD'] == 'GET') {
         $method = 'get';
     } elseif ($_SERVER['REQUEST_METHOD'] == 'PUT') {
         $method = 'put';
         parse_str(file_get_contents("php://input"), $put_vars);
     } elseif ($_SERVER['REQUEST_METHOD'] == 'POST') {
         $method = 'post';
     } else {
         echo 'internal server error: method not supported';
         exit;
     }
     // preprocess url
     $url = $_SERVER['REQUEST_URI'];
     if (substr($url, strlen($url) - 1) != '/') {
         $url .= '/';
     }
     $ex = explode('/', $url);
     $paracount = count($ex);
     // eventhandler
     // CONFIG
     // apiconfig - GET - CONFIG
     if ($method == 'get' and strtolower($ex[$paracount - 3]) == 'v1.php' and strtolower($ex[$paracount - 2]) == 'config') {
         $format = OC_OCS::readdata('format', 'text');
         OC_OCS::apiconfig($format);
         // PERSON
         // personcheck - POST - PERSON/CHECK
     } elseif ($method == 'post' and strtolower($ex[$paracount - 4]) == 'v1.php' and strtolower($ex[$paracount - 3]) == 'person' and strtolower($ex[$paracount - 2]) == 'check') {
         $format = OC_OCS::readdata('format', 'text');
         $login = OC_OCS::readdata('login', 'text');
         $passwd = OC_OCS::readdata('password', 'text');
         OC_OCS::personcheck($format, $login, $passwd);
         // ACTIVITY
         // activityget - GET ACTIVITY   page,pagesize als urlparameter
     } elseif ($method == 'get' and strtolower($ex[$paracount - 3]) == 'v1.php' and strtolower($ex[$paracount - 2]) == 'activity') {
         $format = OC_OCS::readdata('format', 'text');
         $page = OC_OCS::readdata('page', 'int');
         $pagesize = OC_OCS::readdata('pagesize', 'int');
         if ($pagesize < 1 or $pagesize > 100) {
             $pagesize = 10;
         }
         OC_OCS::activityget($format, $page, $pagesize);
         // activityput - POST ACTIVITY
     } elseif ($method == 'post' and strtolower($ex[$paracount - 3]) == 'v1.php' and strtolower($ex[$paracount - 2]) == 'activity') {
         $format = OC_OCS::readdata('format', 'text');
         $message = OC_OCS::readdata('message', 'text');
         OC_OCS::activityput($format, $message);
         // PRIVATEDATA
         // get - GET DATA
     } elseif ($method == 'get' and strtolower($ex[$paracount - 4]) == 'v1.php' and strtolower($ex[$paracount - 2]) == 'getattribute') {
         $format = OC_OCS::readdata('format', 'text');
         OC_OCS::privateDataGet($format);
     } elseif ($method == 'get' and strtolower($ex[$paracount - 5]) == 'v1.php' and strtolower($ex[$paracount - 3]) == 'getattribute') {
         $format = OC_OCS::readdata('format', 'text');
         $app = $ex[$paracount - 2];
         OC_OCS::privateDataGet($format, $app);
     } elseif ($method == 'get' and strtolower($ex[$paracount - 6]) == 'v1.php' and strtolower($ex[$paracount - 4]) == 'getattribute') {
         $format = OC_OCS::readdata('format', 'text');
         $key = $ex[$paracount - 2];
         $app = $ex[$paracount - 3];
         OC_OCS::privateDataGet($format, $app, $key);
         // set - POST DATA
     } elseif ($method == 'post' and strtolower($ex[$paracount - 6]) == 'v1.php' and strtolower($ex[$paracount - 4]) == 'setattribute') {
         $format = OC_OCS::readdata('format', 'text');
         $key = $ex[$paracount - 2];
         $app = $ex[$paracount - 3];
         $value = OC_OCS::readdata('value', 'text');
         OC_OCS::privatedataset($format, $app, $key, $value);
         // delete - POST DATA
     } elseif ($method == 'post' and strtolower($ex[$paracount - 6]) == 'v1.php' and strtolower($ex[$paracount - 4]) == 'deleteattribute') {
         $format = OC_OCS::readdata('format', 'text');
         $key = $ex[$paracount - 2];
         $app = $ex[$paracount - 3];
         OC_OCS::privatedatadelete($format, $app, $key);
     } else {
         $format = OC_OCS::readdata('format', 'text');
         $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);
     }
     exit;
 }