Exemple #1
0
 public function preDispatch()
 {
     parent::preDispatch();
     $this->_helper->layout->disableLayout();
     $this->getHelper('viewRenderer')->setNoRender();
     $this->_jsonServer->setClass($this->_getHandleClassName());
     $this->_jsonServer->handle();
 }
 public function indexAction()
 {
     $server = new Zend_Json_Server();
     $x = new Agana_Service_Test();
     $server->setClass('Agana_Service_Test');
     echo $server->getServiceMap();
     exit;
 }
 public function serviceAction()
 {
     $class = 'Admin_Model_RPC';
     $server = new Zend_Json_Server();
     $server->setClass($class);
     $server->setAutoEmitResponse(true);
     $server->handle();
     exit;
 }
 /**
  * Defined by Zend_Application_Resource_Resource
  *
  * @return Zend_Json_Server
  */
 public function init()
 {
     $aOptions = $this->getOptions();
     $oJsonServer = new Zend_Json_Server();
     foreach ($aOptions['classes'] as $sClassName => $sAlias) {
         $oJsonServer->setClass($sClassName, $sAlias);
     }
     return $oJsonServer;
 }
 /**
  * Start a JSON-RPC server, passing the handler class.
  * @param string $service_class
  */
 public function service($service_class)
 {
     $request = new Zend_Json_Server_Request();
     $request->setOptions(array("method" => $this->_request->getParam("method"), "id" => $this->_request->getParam("id"), "params" => $this->_request->getParam("params")));
     $server = new Zend_Json_Server();
     $server->setClass($service_class);
     $server->handle($request);
     exit;
 }
Exemple #6
0
 /**
  * Cache a service map description (SMD) to a file
  *
  * Returns true on success, false on failure
  *
  * @param  string $filename
  * @param  Zend_Json_Server $server
  * @return boolean
  */
 public static function saveSmd($filename, Zend_Json_Server $server)
 {
     if (!is_string($filename) || !file_exists($filename) && !is_writable(dirname($filename))) {
         return false;
     }
     if (0 === @file_put_contents($filename, $server->getServiceMap()->toJson())) {
         return false;
     }
     return true;
 }
 /**
  * get json-api service map
  * 
  * @return string
  */
 public static function getServiceMap()
 {
     $server = new Zend_Json_Server();
     $server->setClass('Setup_Frontend_Json', 'Setup');
     $server->setClass('Tinebase_Frontend_Json', 'Tinebase');
     $server->setTarget('setup.php')->setEnvelope(Zend_Json_Server_Smd::ENV_JSONRPC_2);
     $smd = $server->getServiceMap();
     $smdArray = $smd->toArray();
     unset($smdArray['methods']);
     return $smdArray;
 }
 public function json()
 {
     $vo_server = new Zend_Json_Server();
     $vo_server->setClass('ItemInfoService', null, null, $this->request);
     if ('GET' == $_SERVER['REQUEST_METHOD']) {
         $vo_server->setTarget(__CA_URL_ROOT__ . '/service.php/iteminfo/ItemInfo/json')->setEnvelope(Zend_Json_Server_Smd::ENV_JSONRPC_2);
         $this->view->setVar("show_smd", true);
     }
     $this->view->setVar("json_server", $vo_server);
     $this->render("iteminfo_json.php");
 }
 /**
  * JSON SERVER
  */
 public function jsonAction()
 {
     $server = new Zend_Json_Server();
     $server->setClass('My_Application_Model_Data');
     if ('GET' == $_SERVER['REQUEST_METHOD']) {
         $server->setTarget($this->_url)->setEnvelope(Zend_Json_Server_Smd::ENV_JSONRPC_2);
         $smd = $server->getServiceMap();
         header('Content-Type: application/json');
         echo $smd;
         return;
     }
     echo $server->handle();
 }
 public function jsonAction()
 {
     $server = new Zend_Json_Server();
     $server->setClass('My_Server_Ventas');
     if ('GET' == $_SERVER['REQUEST_METHOD']) {
         $server->setEnvelope(Zend_Json_Server_Smd::ENV_JSONRPC_2);
         $smd = $server->getServiceMap();
         //header('Content-Type: application/json');
         echo $smd;
         return;
     }
     $server->handle();
 }
 public function jsonAction()
 {
     $this->_helper->viewRenderer->setNoRender();
     $server = new Zend_Json_Server();
     $server->setClass('Application_Model_Data', 'cf');
     if ('GET' == $_SERVER['REQUEST_METHOD']) {
         $server->setTarget('http://localhost/xmlrpc-test/public/server/json')->setEnvelope(Zend_Json_Server_Smd::ENV_JSONRPC_2);
         $smd = $server->getServiceMap();
         header('Content-Type: application/json');
         echo $smd;
         return;
     }
     echo $server->handle();
 }
Exemple #12
0
 public function handle($request = false)
 {
     if ($request->isParseError()) {
         $this->fault('Parse error', -32700);
     }
     return parent::handle($request);
 }
 /**
  * JSON-RPC controller
  *
  * @return void
  */
 public function indexAction()
 {
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender();
     $server = new Zend_Json_Server();
     $server->setClass('WorklogService');
     if ('GET' == $_SERVER['REQUEST_METHOD']) {
         $server->setTarget('/rpc/index')->setEnvelope(Zend_Json_Server_Smd::ENV_JSONRPC_2)->setDojoCompatible(true);
         $smd = $server->getServiceMap();
         header('Content-Type: application/json');
         echo $smd;
         return;
     }
     // Handle the request:
     $server->handle();
 }
 /**
  * JSON CLIENT
  */
 public function jsonAction()
 {
     $server = new Zend_Json_Server();
     $server->setClass('My_Application_Model_Data');
     if ('GET' == $_SERVER['REQUEST_METHOD']) {
         $server->setTarget($this->_url)->setEnvelope(Zend_Json_Server_Smd::ENV_JSONRPC_2);
         $smd = $server->getServiceMap();
         if (isset($_GET['method'])) {
             //On recupere les methodes depuis le service map
             $arrSmd = Zend_Json::decode($smd);
             //Construction du tableau contenant les liens des methodes
             $links = '<h2>' . 'Liste des methodes JSON' . '</h2>' . '<table>' . '<tr>';
             foreach ($arrSmd["services"] as $serv => $value) {
                 $links .= '<td width="100px" align="center">' . '<a href="' . $this->_url . '?method=' . $serv . '">' . $serv . '</a>' . '</td>';
             }
             $links .= '</tr>' . '</table>';
             //Envoi du tableau a la vue
             $this->view->links = $links;
             //On recupere la methode appelee
             $method = $_GET['method'];
             $nbParam = 0;
             //Nombre de parametre de la methode
             //On cree un formulaire contenant les parametres
             $formtxt = '<form name="' . $method . '" method="post">' . '<table>';
             foreach ($smd->getService($method)->getParams() as $param) {
                 $formtxt .= '<tr>' . '<td>' . $param['name'] . ' (' . $param['type'] . ') :</td>' . '<td><input type=text name="' . $param['name'] . '"></td>' . '<tr>';
                 $nbParam++;
             }
             $formtxt .= '<tr>' . '<td></td>' . '<td><input type=submit value=Envoyer></td>' . '</tr>' . '</table>' . '</form>';
             //On envoi le formulaire a la vue json client
             $this->view->form = $formtxt;
             //On envoi le nom de la methode traitee a la vue
             $this->view->method = $method;
             //On envoi le nombre de parametres du formulaire a la vue
             $this->view->nbParam = $nbParam;
         } else {
             $this->_helper->viewRenderer->setNoRender(true);
             header('Content-Type: application/json');
             echo $smd;
             return;
         }
     } else {
         $this->_helper->viewRenderer->setNoRender();
         echo $server->handle();
     }
 }
Exemple #15
0
 /**
  * handler for JSON api requests
  * 
  * @return JSON
  */
 public function handle()
 {
     try {
         // init server and request first
         $server = new Zend_Json_Server();
         $server->setClass('Setup_Frontend_Json', 'Setup');
         $server->setClass('Tinebase_Frontend_Json', 'Tinebase');
         $server->setAutoHandleExceptions(false);
         $server->setAutoEmitResponse(false);
         $request = new Zend_Json_Server_Request_Http();
         Setup_Core::initFramework();
         $method = $request->getMethod();
         $jsonKey = isset($_SERVER['HTTP_X_TINE20_JSONKEY']) ? $_SERVER['HTTP_X_TINE20_JSONKEY'] : '';
         Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' is JSON request. method: ' . $method);
         $anonymnousMethods = array('Setup.getAllRegistryData', 'Setup.login', 'Tinebase.getAvailableTranslations', 'Tinebase.getTranslations', 'Tinebase.setLocale');
         if (!Setup_Core::configFileExists()) {
             $anonymnousMethods = array_merge($anonymnousMethods, array('Setup.envCheck'));
         }
         // check json key for all methods but some exceptoins
         if (!in_array($method, $anonymnousMethods) && Setup_Core::configFileExists() && (empty($jsonKey) || $jsonKey != Setup_Core::get('jsonKey') || !Setup_Core::isRegistered(Setup_Core::USER))) {
             if (!Setup_Core::isRegistered(Setup_Core::USER)) {
                 Setup_Core::getLogger()->INFO(__METHOD__ . '::' . __LINE__ . ' Attempt to request a privileged Json-API method without authorisation from "' . $_SERVER['REMOTE_ADDR'] . '". (session timeout?)');
                 throw new Tinebase_Exception_AccessDenied('Not Authorised', 401);
             } else {
                 Setup_Core::getLogger()->WARN(__METHOD__ . '::' . __LINE__ . ' Fatal: got wrong json key! (' . $jsonKey . ') Possible CSRF attempt!' . ' affected account: ' . print_r(Setup_Core::getUser(), true) . ' request: ' . print_r($_REQUEST, true));
                 throw new Tinebase_Exception_AccessDenied('Not Authorised', 401);
             }
         }
         $response = $server->handle($request);
     } catch (Exception $exception) {
         $response = $this->_handleException($server, $request, $exception);
     }
     echo $response;
 }
 public function indexAction()
 {
     // Instantiate server, etc.
     $server = new Zend_Json_Server();
     Zend_Registry::set("fileserver_helper", $this->_fileHelper);
     $server->setClass('Admin_Model_FileServer');
     if ('GET' == $_SERVER['REQUEST_METHOD']) {
         // Indicate the URL endpoint, and the JSON-RPC version used:
         $server->setTarget('/file-server/')->setEnvelope(Zend_Json_Server_Smd::ENV_JSONRPC_2);
         // Grab the SMD
         $smd = $server->getServiceMap();
         // Return the SMD to the client
         header('Content-Type: application/json');
         echo $smd;
         die;
     }
     $server->handle();
     die;
 }
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */
set_include_path(get_include_path() . PATH_SEPARATOR . 'include/');
require_once 'Zend/Loader/Autoloader.php';
$loader = Zend_Loader_Autoloader::getInstance();
$loader->registerNamespace('CnCNet_');
unset($loader);
$db = Zend_Db::factory('Pdo_Sqlite', array('dbname' => 'db/cncnet.db'));
Zend_Db_Table::setDefaultAdapter($db);
$db->query('PRAGMA foreign_keys = ON');
unset($db);
$type = isset($_GET['type']) ? $_GET['type'] : 'json';
if ($type == 'json' || $type == 'jsonp') {
    $server = new Zend_Json_Server();
    $server->setClass('CnCNet_Api');
    if ($type == 'jsonp') {
        $server->setRequest(new CnCNet_Json_Server_Request_Http_Jsonp());
        $server->setResponse(new CnCNet_Json_Server_Response_Http_Jsonp());
    } else {
        if ($_SERVER['REQUEST_METHOD'] == 'GET') {
            echo $server->setEnvelope(Zend_Json_Server_Smd::ENV_JSONRPC_2)->getServiceMap();
            return;
        }
    }
    $server->handle();
} else {
    if ($type == 'xml') {
        header('Content-type: text/xml');
        $server = new Zend_XmlRpc_Server();
Exemple #18
0
<?php

require_once dirname(__FILE__) . '/bootstrap.php';
$plugin = Zend_Registry::get('init');
$request = $plugin->getRequest();
$plugin->initDb();
$loader = new My_Controller_Helper_ResourceLoader();
$loader->initModule('spindle');
$paste = $loader->getService('Paste');
$server = new Zend_Json_Server();
$server->setClass($paste);
if ($request->isGet()) {
    $server->setTarget($request->getBaseUrl() . '/jsonrpc')->setEnvelope(Zend_Json_Server_Smd::ENV_JSONRPC_2);
    // Grab the SMD
    $smd = $server->getServiceMap();
    // Cache the SMD
    if ('production' == APPLICATION_ENV && is_writeable(dirname(__FILE__))) {
        file_put_contents(dirname(__FILE__) . '/content/jsonrpc.smd', $smd);
    }
    // Return the SMD to the client
    header('Content-Type: application/json');
    echo $smd;
    return;
}
$server->handle();
 public function testLoadFunctionsShouldLoadResultOfGetFunctions()
 {
     $this->server->setClass('Zend_Json_ServerTest_Foo');
     $functions = $this->server->getFunctions();
     $server = new Zend_Json_Server();
     $server->loadFunctions($functions);
     $this->assertEquals($functions->toArray(), $server->getFunctions()->toArray());
 }
Exemple #20
0
// Create application, bootstrap, and run
$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/config.php');
/**
 * Bootstrap the whole app for now.
 * This should be adjusted in the future for performance gains.
 */
$application->bootstrap();
/**
 * Force the cache manager because for some reason it ends up empty without
 * setting the manager manually
 */
$cache = Zend_Controller_Action_HelperBroker::getStaticHelper('Cache');
$cache->setManager($application->getBootstrap()->getResource('cachemanager'));
switch ($_GET['format']) {
    case 'json':
        $server = new Zend_Json_Server();
        // Indicate the URL endpoint, and the JSON-RPC version used:
        $server->setTarget('/api/jsonrpc/')->setEnvelope(Zend_Json_Server_Smd::ENV_JSONRPC_2);
        $contentTypeHeader = 'Content-Type: text/json';
        break;
    case 'xml':
        $server = new Zend_XmlRpc_Server();
        Zend_XmlRpc_Server_Fault::attachFaultException('FFR_Exception');
        Zend_XmlRpc_Server_Fault::attachFaultException('Zend_Exception');
        $contentTypeHeader = 'Content-Type: text/xml';
        break;
}
$apiList = Zym_Message_Dispatcher::get()->post('buildApi')->getResult('buildApi');
foreach ($apiList as $key => $services) {
    foreach ($services as $service => $class) {
        $server->setClass($class, $service);
 function testHandleException()
 {
     $server = new Zend_Json_Server();
     $server->addFunction('Zend_Json_Server_TestFunc10');
     ob_start();
     $server->handle(array('method' => 'Zend_Json_Server_TestFunc10'));
     ob_end_clean();
     ob_start();
     $server->fault(new Exception('An error occurred.', 404));
     $result = ob_get_clean();
     $this->assertEquals('{"msg" : "An error occurred.", "code" : 404}', $result, "Bad Response");
 }
 function testHandleReturnObject()
 {
     $server = new Zend_Json_Server();
     $server->addFunction('Zend_Json_Server_TestFunc8');
     ob_start();
     $server->handle(array('method' => 'Zend_Json_Server_TestFunc8'));
     $result = ob_get_clean();
     $this->assertEquals('{"__className": "stdClass", "foo" : "bar", "baz" : true, "bat" : 123, "qux" : false, "status" : "success"}', $result, "Bas Response");
 }
Exemple #23
0
 *
 * - Ensure library/ is on include_path
 * - Register Autoloader
 */
defined('APPLICATION_PATH') || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../'));
set_include_path(implode(PATH_SEPARATOR, array(realpath(APPLICATION_PATH . '/libraries/'))));
require_once 'Zend/Loader/Autoloader.php';
$autoloader = Zend_Loader_Autoloader::getInstance();
/**
 * ==================================================================
 * Prepare environment and execute JSON calls
 * ==================================================================
 */
require APPLICATION_PATH . '/includes/classes/remote.class.php';
header('Access-Control-Allow-Origin: *');
$server = new Zend_Json_Server();
$server->setClass('Kimai_Remote_Api');
if ('GET' == $_SERVER['REQUEST_METHOD']) {
    // Indicate the URL endpoint, and the JSON-RPC version used:
    $server->setTarget('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'])->setEnvelope(Zend_Json_Server_Smd::ENV_JSONRPC_2);
    // Grab the SMD
    $smd = $server->getServiceMap();
    // Return the SMD to the client
    header('Content-Type: application/json');
    echo $smd;
    return;
}
/**
 * http request will 
 *  - parse php://input 
 *  - json_decode it
Exemple #24
0
 /**
  * Override of run method to provide JSON server interface
  *
  * @return void
  */
 public function run()
 {
     if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') {
         // run Zend_Json_Server instead of the MVC stack
         $request = new Zend_Controller_Request_Http();
         $info = explode('/', trim($request->getPathInfo(), '/'));
         $module = $info[0];
         $service = $info[1];
         // attach the service to the JSON-RPC server
         $service = $this->_loadService($module, $service);
         $server = new Zend_Json_Server();
         $server->setClass($service);
         if ('GET' == $_SERVER['REQUEST_METHOD']) {
             // return the service map
             $server->setEnvelope(Zend_Json_Server_Smd::ENV_JSONRPC_2);
             $smd = $server->getServiceMap();
             header('Content-Type: application/json');
             echo $smd;
             return;
         }
         $server->handle();
     } else {
         parent::run();
     }
 }
 /**
  * Verarbeitet einen Aufruf des Json Servers
  * @param Dragon_Json_Server_Request_Http $request
  * @return mixed|null|Zend_Json_Server_Response
  * @throws InvalidArgumentException
  */
 public function handle($request = null)
 {
     $requestmethod = null;
     if (isset($request)) {
         if (!$request instanceof Dragon_Json_Server_Request_Http) {
             throw new Dragon_Application_Exception_System('incorrect requestclass', array('requestclass' => get_class($request)));
         }
         $requestmethod = 'POST';
     } else {
         $request = new Dragon_Json_Server_Request_Http();
     }
     if (!isset($requestmethod)) {
         $requestmethod = $_SERVER['REQUEST_METHOD'];
     }
     $configCache = new Dragon_Application_Config('dragon/json/cache');
     if (!isset($configCache->filepath) || !Zend_Server_Cache::get($configCache->filepath, $this)) {
         $configRoute = new Dragon_Application_Config('dragon/json/route');
         $packageregistry = Zend_Registry::get('Dragon_Package_Registry');
         foreach ($packageregistry->getClassnames('Service') as $servicename) {
             if (isset($configRoute->{$servicename})) {
                 $routename = $configRoute->{$servicename};
             } else {
                 $routename = str_replace('_', '.', $servicename);
             }
             $this->setClass($servicename, $routename);
         }
         if (isset($configCache->filepath)) {
             Zend_Server_Cache::save($configCache->filepath, $this);
         }
     }
     switch ($requestmethod) {
         case 'POST':
             $this->setResponse(new Dragon_Json_Server_Response_Http());
             $autoemitresponse = $this->autoEmitResponse();
             if ($autoemitresponse) {
                 $this->setAutoEmitResponse(false);
             }
             $response = parent::handle($request);
             $result = $response->getResult();
             if (isset($result['result'])) {
                 $subresult =& $result['result'];
             } else {
                 $subresult =& $result;
             }
             if (is_array($subresult)) {
                 foreach ($request->getMap() as $key => $value) {
                     if (isset($subresult[$key])) {
                         $subresult[$value] = $subresult[$key];
                     }
                 }
                 $response->setResult($result);
             }
             if ($autoemitresponse) {
                 $this->setAutoEmitResponse(true);
                 echo $response;
                 return;
             }
             return $response;
             break;
         case 'GET':
             header('Content-Type: application/json');
             $servicemap = $this->getServiceMap();
             Zend_Registry::get('Dragon_Plugin_Registry')->invoke('Dragon_Json_Plugin_Servicemap_Interface', array($servicemap));
             echo $servicemap;
             break;
     }
 }
Exemple #26
0
	/**
	 * JSONRPC server
	 */
	public function jsonrpcAction() 
	{
		$server = new Zend_Json_Server();
		$server->setClass( 'User_Service_User', 'user' );
		echo $server->handle();
	}
function example($cycle)
{
    $server = new Zend_Json_Server();
    $server->setClass('WOPR_Test_Example');
    return $cycle->send($server->handle(), Cycle_Response::JSON);
}
 /**
  * JSON-RPC entrance.
  *
  * @return Void
  */
 public function apiAction()
 {
     Zend_Registry::set('CMS', true);
     /**
      * Prepare the server. Zend_Json_Server cannot work with batched requests natively,
      * so that's taken care of customly here. Therefore, autoEmitResponse is set to false
      * so the server doesn't print the response directly.
      */
     $server = new Zend_Json_Server();
     $server->setClass('Garp_Content_Manager_Proxy');
     $server->setAutoEmitResponse(false);
     if ($this->getRequest()->isPost()) {
         $post = $this->_getJsonRpcRequest();
         $batch = false;
         $responses = array();
         $requests = Zend_Json::decode($post, Zend_Json::TYPE_ARRAY);
         /**
          * Check if this was a batch request. In that case the array is a plain array of
          * arrays. If not, there will be a 'jsonrpc' key in the root of the array.
          */
         $batch = !array_key_exists('jsonrpc', $requests);
         if (!$batch) {
             $requests = array($requests);
         }
         foreach ($requests as $i => $request) {
             $request = $this->_reformJsonRpcRequest($request);
             $requestJson = Zend_Json::encode($request);
             $requestObj = new Zend_Json_Server_Request();
             $requestObj->loadJson($requestJson);
             $server->setRequest($requestObj);
             /**
              * Note; response gets returned by reference, resulting in a $responses array
              * containing all the same items.
              * That's why clone is used here.
              */
             $response = clone $server->handle();
             $responses[] = $response;
         }
         $response = $batch ? '[' . implode(',', $responses) . ']' : $responses[0];
     } else {
         $response = $server->getServiceMap();
     }
     $this->_helper->layout->setLayout('json');
     //  filter out escaped slashes, because they're annoying and not necessary.
     $response = str_replace('\\/', '/', $response);
     $this->view->response = $response;
 }
Exemple #29
0
<?php

set_include_path(get_include_path() . PATH_SEPARATOR . ZF_APPLICATION_DIRECTORY . '/rpc');
$request = new Zend_Controller_Request_Http();
$response = new Zend_Controller_Response_Http();
$channel = Zend_Wildfire_Channel_HttpHeaders::getInstance();
$channel->setRequest($request);
$channel->setResponse($response);
ob_start();
try {
    $server = new Zend_Json_Server();
    $server->setClass($request->getParam('endpoint'))->setTarget('json-rpc/' . $request->getParam('endpoint'))->setEnvelope('JSON-RPC-1.0')->setDojoCompatible(true);
    // For GET requests, simply return the service map
    switch ($_SERVER['REQUEST_METHOD']) {
        case 'GET':
            $smd = $server->getServiceMap();
            header('Content-Type: application/json');
            echo $smd;
            break;
        case 'POST':
            $server->handle();
            break;
    }
} catch (Exception $e) {
    $logger->err($e);
}
$channel->flush();
$response->sendHeaders();
 /**
  * get JSON from cache or new instance
  * 
  * @param array $classes for Zend_Cache_Frontend_File
  * @return Zend_Json_Server
  */
 protected static function _getServer($classes = null)
 {
     // setup cache if available
     if (is_array($classes) && Tinebase_Core::getCache()) {
         $masterFiles = array();
         $dirname = dirname(__FILE__) . '/../../';
         foreach ($classes as $class => $namespace) {
             $masterFiles[] = $dirname . str_replace('_', '/', $class) . '.php';
         }
         try {
             $cache = new Zend_Cache_Frontend_File(array('master_files' => $masterFiles, 'lifetime' => null, 'automatic_serialization' => true, 'automatic_cleaning_factor' => 0, 'write_control' => false, 'logging' => Tinebase_Core::isLogLevel(Zend_Log::DEBUG), 'logger' => Tinebase_Core::getLogger()));
             $cache->setBackend(Tinebase_Core::getCache()->getBackend());
             $cacheId = Tinebase_Helper::convertCacheId('_handle_' . sha1(Zend_Json_Encoder::encode($classes)) . '_' . (self::userIsRegistered() ? Tinebase_Core::getUser()->getId() : 'anon'));
             $server = $cache->load($cacheId);
             if ($server instanceof Zend_Json_Server) {
                 return $server;
             }
         } catch (Zend_Cache_Exception $zce) {
             if (Tinebase_Core::isLogLevel(Zend_Log::NOTICE)) {
                 Tinebase_Core::getLogger()->notice(__METHOD__ . '::' . __LINE__ . " Failed to create cache. Exception: \n" . $zce);
             }
         }
     }
     $server = new Zend_Json_Server();
     $server->setAutoEmitResponse(false);
     $server->setAutoHandleExceptions(false);
     if (is_array($classes)) {
         foreach ($classes as $class => $namespace) {
             try {
                 $server->setClass($class, $namespace);
             } catch (Exception $e) {
                 if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
                     Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . " Failed to add JSON API for '{$class}' => '{$namespace}' Exception: \n" . $e);
                 }
             }
         }
     }
     if (self::userIsRegistered()) {
         $definitions = self::_getModelConfigMethods();
         $server->loadFunctions($definitions);
     }
     if (isset($cache)) {
         $cache->save($server, $cacheId, array(), null);
     }
     return $server;
 }