/[cvs]/nfo/php/libs/org.netfrag.glib/DesignPattern/RemoteProxy.php
ViewVC logotype

Diff of /nfo/php/libs/org.netfrag.glib/DesignPattern/RemoteProxy.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.13 by joko, Fri Apr 4 17:38:03 2003 UTC revision 1.18 by jonen, Thu May 13 19:17:55 2004 UTC
# Line 18  Line 18 
18   *    $Id$   *    $Id$
19   * -------------------------------------------------------------------------   * -------------------------------------------------------------------------
20   *    $Log$   *    $Log$
21     *    Revision 1.18  2004/05/13 19:17:55  jonen
22     *    + bugfix: utf8 conversion was missing at some backend-calls
23     *
24     *    Revision 1.17  2003/07/14 10:05:23  jonen
25     *    bugfix: added *needed* function 'getAttributes'
26     *
27     *    Revision 1.16  2003/07/02 13:51:38  jonen
28     *    removed debug dumper
29     *
30     *    Revision 1.15  2003/04/11 01:32:21  joko
31     *    renamed logging function
32     *
33     *    Revision 1.14  2003/04/09 02:06:45  joko
34     *    errormessage now shown preformatted
35     *
36   *    Revision 1.13  2003/04/04 17:38:03  joko   *    Revision 1.13  2003/04/04 17:38:03  joko
37   *    modifications regarding error-/exception-handling and -tracing   *    modifications regarding error-/exception-handling and -tracing
38   *   *
# Line 266  class DesignPattern_RemoteProxy extends Line 281  class DesignPattern_RemoteProxy extends
281    var $backend;    var $backend;
282    
283    function DesignPattern_RemoteProxy($objectId = "", $options = array() ) {    function DesignPattern_RemoteProxy($objectId = "", $options = array() ) {
284      logp(get_class($this) . "->new()", PEAR_LOG_INFO);      php::log(get_class($this) . "->new()", PEAR_LOG_INFO);
285      global $proxy;      global $proxy;
286    
287      // 2003-03-05 - modified constructor      // 2003-03-05 - modified constructor
# Line 330  class DesignPattern_RemoteProxy extends Line 345  class DesignPattern_RemoteProxy extends
345    
346    
347    function load() {    function load() {
348      logp(get_class($this) . "->load()", PEAR_LOG_INFO);      php::log(get_class($this) . "->load()", PEAR_LOG_INFO);
349      if (!$this->_loadState()) {      if (!$this->_loadState()) {
350        if (!$this->_loadProxy()) {        if (!$this->_loadProxy()) {
351    
# Line 387  class DesignPattern_RemoteProxy extends Line 402  class DesignPattern_RemoteProxy extends
402      $this->attributes = $data;      $this->attributes = $data;
403    }    }
404    
405      function getAttributes() {
406        return $this->attributes;
407      }
408    
409    function flushProxy() {    function flushProxy() {
410          connectdb();          connectdb();
411      $sql = "DELETE FROM f_proxy WHERE oid='$this->objectId'";      $sql = "DELETE FROM f_proxy WHERE oid='$this->objectId'";
# Line 406  class DesignPattern_RemoteProxy extends Line 425  class DesignPattern_RemoteProxy extends
425        //print Dumper($this);        //print Dumper($this);
426    
427      // debug      // debug
428        logp(get_class($this) . "->_loadState()");        php::log(get_class($this) . "->_loadState()");
429                
430      if ($this->attributes = $proxy[$this->objectId]) {      if ($this->attributes = $proxy[$this->objectId]) {
431        //print "_loadState:" . dumpVar($this->attributes);        //print "_loadState:" . dumpVar($this->attributes);
# Line 418  class DesignPattern_RemoteProxy extends Line 437  class DesignPattern_RemoteProxy extends
437    
438    function _saveState() {    function _saveState() {
439      global $proxy;      global $proxy;
440      logp(get_class($this) . "->_saveState()");      php::log(get_class($this) . "->_saveState()");
441      $proxy[$this->objectId] = $this->attributes;      $proxy[$this->objectId] = $this->attributes;
442      //print "_saveState: " . dumpVar($this->attributes);      //print "_saveState: " . dumpVar($this->attributes);
443      // TODO: throw exception-message back to user if operation fails      // TODO: throw exception-message back to user if operation fails
# Line 431  class DesignPattern_RemoteProxy extends Line 450  class DesignPattern_RemoteProxy extends
450            
451      // trace & debug      // trace & debug
452        //print Dumper($this);        //print Dumper($this);
453        logp(get_class($this) . "->_loadProxy()");        php::log(get_class($this) . "->_loadProxy()");
454                
455      connectdb();      connectdb();
456      $sql = "SELECT payload FROM f_proxy WHERE oid='$this->objectId'";      $sql = "SELECT payload FROM f_proxy WHERE oid='$this->objectId'";
# Line 451  class DesignPattern_RemoteProxy extends Line 470  class DesignPattern_RemoteProxy extends
470      // FIXME!      // FIXME!
471      if (!$this->meta[cache][db]) { return; }      if (!$this->meta[cache][db]) { return; }
472    
473      logp(get_class($this) . "->_saveProxy()");      php::log(get_class($this) . "->_saveProxy()");
474          connectdb();          connectdb();
475          if ($this->payload) {          if ($this->payload) {
476        //$sql = "INSERT INTO f_proxy SET payload='$this->payload' WHERE oid='$this->objectId'";        //$sql = "INSERT INTO f_proxy SET payload='$this->payload' WHERE oid='$this->objectId'";
# Line 464  class DesignPattern_RemoteProxy extends Line 483  class DesignPattern_RemoteProxy extends
483    }    }
484        
485    function _loadRemote() {    function _loadRemote() {
486      logp(get_class($this) . "->_loadRemote()");      php::log(get_class($this) . "->_loadRemote()");
487            
488      // trace      // trace
489        //print Dumper($this->meta);        //print Dumper($this->meta);
# Line 473  class DesignPattern_RemoteProxy extends Line 492  class DesignPattern_RemoteProxy extends
492            
493      // 1. check backend-handle      // 1. check backend-handle
494      if (!$this->backend) {      if (!$this->backend) {
495        logp(get_class($this) . "->_loadRemote: no backend handle, please check argument 'rpcinfo'", PEAR_LOG_CRIT);        php::log(get_class($this) . "->_loadRemote: no backend handle, please check argument 'rpcinfo'", PEAR_LOG_CRIT);
496        return;        return;
497      }      }
498            
# Line 481  class DesignPattern_RemoteProxy extends Line 500  class DesignPattern_RemoteProxy extends
500        // check for guid or oid        // check for guid or oid
501        if ($this->meta[guid]) {        if ($this->meta[guid]) {
502          if (!$this->objectId) {          if (!$this->objectId) {
503            logp(get_class($this) . "->_loadRemote: argument 'guid' requires valid objectId", PEAR_LOG_WARNING);            php::log(get_class($this) . "->_loadRemote: argument 'guid' requires valid objectId", PEAR_LOG_WARNING);
504            return;            return;
505          }          }
506          if (!$this->meta[classname]) {          if (!$this->meta[classname]) {
507            logp(get_class($this) . "->_loadRemote: argument 'guid' requires 'classname'", PEAR_LOG_WARNING);            php::log(get_class($this) . "->_loadRemote: argument 'guid' requires 'classname'", PEAR_LOG_WARNING);
508            return;            return;
509          }          }
510          logp(get_class($this) . "->_loadRemote: getObjectByGuid", PEAR_LOG_DEBUG);          php::log(get_class($this) . "->_loadRemote: getObjectByGuid", PEAR_LOG_DEBUG);
511          $args = array( guid => $this->objectId, classname => $this->meta[classname] );          $args = array( guid => $this->objectId, classname => $this->meta[classname] );
512          $result = $this->backend->send('getObjectByGuid', $args );          $result = $this->backend->send('getObjectByGuid', $args, array( utf8 => 1)  );
513    
514        } elseif ($this->meta[oid]) {        } elseif ($this->meta[oid]) {
515          if (!$this->objectId) {          if (!$this->objectId) {
516            logp(get_class($this) . "->_loadRemote: argument 'oid' requires valid objectId", PEAR_LOG_WARNING);            php::log(get_class($this) . "->_loadRemote: argument 'oid' requires valid objectId", PEAR_LOG_WARNING);
517            return;            return;
518          }          }
519          logp(get_class($this) . "->_loadRemote: getObject", PEAR_LOG_DEBUG);          php::log(get_class($this) . "->_loadRemote: getObject", PEAR_LOG_DEBUG);
520          $result = $this->backend->send('getObject', $this->objectId);          $result = $this->backend->send('getObject', $this->objectId, array( utf8 => 1) );
521    
522        } elseif ($this->meta[key]) {        } elseif ($this->meta[key]) {
523          if (!$this->meta[command]) {          if (!$this->meta[command]) {
524            logp(get_class($this) . "->_loadRemote: argument 'key' requires 'command'", PEAR_LOG_WARNING);            php::log(get_class($this) . "->_loadRemote: argument 'key' requires 'command'", PEAR_LOG_WARNING);
525            return;            return;
526          }          }
527          /*          /*
528          if (!$this->meta[query]) {          if (!$this->meta[query]) {
529            logp(get_class($this) . "->_loadRemote: argument 'key' requires 'query'", PEAR_LOG_WARNING);            php::log(get_class($this) . "->_loadRemote: argument 'key' requires 'query'", PEAR_LOG_WARNING);
530            return;            return;
531          }          }
532          */          */
533          //logp(get_class($this) . "->_loadRemote: $this->meta[command](" . join(' ', $this->meta[query]) . ")", PEAR_LOG_DEBUG);          //php::log(get_class($this) . "->_loadRemote: $this->meta[command](" . join(' ', $this->meta[query]) . ")", PEAR_LOG_DEBUG);
534          //print Dumper(array($this->meta[command], $this->meta[query]));          //print Dumper(array($this->meta[command], $this->meta[query]));
535          $result = $this->backend->send($this->meta[command], $this->meta[query]);          $result = $this->backend->send($this->meta[command], $this->meta[query], array( utf8 => 1) );
536                    
537        }        }
538    
# Line 560  function draw_error_box($status) { Line 579  function draw_error_box($status) {
579    $statusbox->add( html_span('boxlabel_yellow', "Connected:"), $status[connected], html_br() );    $statusbox->add( html_span('boxlabel_yellow', "Connected:"), $status[connected], html_br() );
580    $statusbox->add( html_span('boxlabel_yellow', "RPCSESSID:"), $status[RPCSESSID], html_br() );    $statusbox->add( html_span('boxlabel_yellow', "RPCSESSID:"), $status[RPCSESSID], html_br() );
581    foreach ($status[errors] as $error) {    foreach ($status[errors] as $error) {
582      $statusbox->add( html_span('boxlabel_yellow', "Error($error[code]):"), $error[message], html_br() );      $msg = html_pre($error[message]);
583        $statusbox->add( html_span('boxlabel_yellow', "Error($error[code]):"), $msg );
584    }    }
585        
586    $message = "Error while talking to remote side. Please check wire, socket or api.";    $message = "Error while talking to remote side. Please check wire, socket or api.";
587    logp($message, PEAR_LOG_CRIT);    php::log($message, PEAR_LOG_CRIT);
588    $statusbox->add( html_span('boxlabel_yellow', "Critical:"), $message, html_br() );    $statusbox->add( html_span('boxlabel_yellow', "Critical:"), $message, html_br() );
589    
590    // V1    // V1
# Line 586  function draw_error_box($status) { Line 606  function draw_error_box($status) {
606    
607    
608    function _saveBackend($result) {    function _saveBackend($result) {
609      logp(get_class($this) . "->_saveBackend()");      php::log(get_class($this) . "->_saveBackend()");
610    
611      //$encoder = new TextEncode($result);      //$encoder = new TextEncode($result);
612      //$encoder->toUTF8();      //$encoder->toUTF8();
# Line 617  function draw_error_box($status) { Line 637  function draw_error_box($status) {
637    
638  }  }
639    
 ?>  
640    ?>

Legend:
Removed from v.1.13  
changed lines
  Added in v.1.18

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed