/[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.15 by joko, Fri Apr 11 01:32:21 2003 UTC
# Line 18  Line 18 
18   *    $Id$   *    $Id$
19   * -------------------------------------------------------------------------   * -------------------------------------------------------------------------
20   *    $Log$   *    $Log$
21     *    Revision 1.15  2003/04/11 01:32:21  joko
22     *    renamed logging function
23     *
24     *    Revision 1.14  2003/04/09 02:06:45  joko
25     *    errormessage now shown preformatted
26     *
27   *    Revision 1.13  2003/04/04 17:38:03  joko   *    Revision 1.13  2003/04/04 17:38:03  joko
28   *    modifications regarding error-/exception-handling and -tracing   *    modifications regarding error-/exception-handling and -tracing
29   *   *
# Line 266  class DesignPattern_RemoteProxy extends Line 272  class DesignPattern_RemoteProxy extends
272    var $backend;    var $backend;
273    
274    function DesignPattern_RemoteProxy($objectId = "", $options = array() ) {    function DesignPattern_RemoteProxy($objectId = "", $options = array() ) {
275      logp(get_class($this) . "->new()", PEAR_LOG_INFO);      php::log(get_class($this) . "->new()", PEAR_LOG_INFO);
276      global $proxy;      global $proxy;
277    
278      // 2003-03-05 - modified constructor      // 2003-03-05 - modified constructor
# Line 330  class DesignPattern_RemoteProxy extends Line 336  class DesignPattern_RemoteProxy extends
336    
337    
338    function load() {    function load() {
339      logp(get_class($this) . "->load()", PEAR_LOG_INFO);      php::log(get_class($this) . "->load()", PEAR_LOG_INFO);
340      if (!$this->_loadState()) {      if (!$this->_loadState()) {
341        if (!$this->_loadProxy()) {        if (!$this->_loadProxy()) {
342    
# Line 406  class DesignPattern_RemoteProxy extends Line 412  class DesignPattern_RemoteProxy extends
412        //print Dumper($this);        //print Dumper($this);
413    
414      // debug      // debug
415        logp(get_class($this) . "->_loadState()");        php::log(get_class($this) . "->_loadState()");
416                
417      if ($this->attributes = $proxy[$this->objectId]) {      if ($this->attributes = $proxy[$this->objectId]) {
418        //print "_loadState:" . dumpVar($this->attributes);        //print "_loadState:" . dumpVar($this->attributes);
# Line 418  class DesignPattern_RemoteProxy extends Line 424  class DesignPattern_RemoteProxy extends
424    
425    function _saveState() {    function _saveState() {
426      global $proxy;      global $proxy;
427      logp(get_class($this) . "->_saveState()");      php::log(get_class($this) . "->_saveState()");
428      $proxy[$this->objectId] = $this->attributes;      $proxy[$this->objectId] = $this->attributes;
429      //print "_saveState: " . dumpVar($this->attributes);      //print "_saveState: " . dumpVar($this->attributes);
430      // 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 437  class DesignPattern_RemoteProxy extends
437            
438      // trace & debug      // trace & debug
439        //print Dumper($this);        //print Dumper($this);
440        logp(get_class($this) . "->_loadProxy()");        php::log(get_class($this) . "->_loadProxy()");
441                
442      connectdb();      connectdb();
443      $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 457  class DesignPattern_RemoteProxy extends
457      // FIXME!      // FIXME!
458      if (!$this->meta[cache][db]) { return; }      if (!$this->meta[cache][db]) { return; }
459    
460      logp(get_class($this) . "->_saveProxy()");      php::log(get_class($this) . "->_saveProxy()");
461          connectdb();          connectdb();
462          if ($this->payload) {          if ($this->payload) {
463        //$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 470  class DesignPattern_RemoteProxy extends
470    }    }
471        
472    function _loadRemote() {    function _loadRemote() {
473      logp(get_class($this) . "->_loadRemote()");      php::log(get_class($this) . "->_loadRemote()");
474            
475      // trace      // trace
476        //print Dumper($this->meta);        //print Dumper($this->meta);
# Line 473  class DesignPattern_RemoteProxy extends Line 479  class DesignPattern_RemoteProxy extends
479            
480      // 1. check backend-handle      // 1. check backend-handle
481      if (!$this->backend) {      if (!$this->backend) {
482        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);
483        return;        return;
484      }      }
485            
# Line 481  class DesignPattern_RemoteProxy extends Line 487  class DesignPattern_RemoteProxy extends
487        // check for guid or oid        // check for guid or oid
488        if ($this->meta[guid]) {        if ($this->meta[guid]) {
489          if (!$this->objectId) {          if (!$this->objectId) {
490            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);
491            return;            return;
492          }          }
493          if (!$this->meta[classname]) {          if (!$this->meta[classname]) {
494            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);
495            return;            return;
496          }          }
497          logp(get_class($this) . "->_loadRemote: getObjectByGuid", PEAR_LOG_DEBUG);          php::log(get_class($this) . "->_loadRemote: getObjectByGuid", PEAR_LOG_DEBUG);
498          $args = array( guid => $this->objectId, classname => $this->meta[classname] );          $args = array( guid => $this->objectId, classname => $this->meta[classname] );
499          $result = $this->backend->send('getObjectByGuid', $args );          $result = $this->backend->send('getObjectByGuid', $args );
500    
501        } elseif ($this->meta[oid]) {        } elseif ($this->meta[oid]) {
502          if (!$this->objectId) {          if (!$this->objectId) {
503            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);
504            return;            return;
505          }          }
506          logp(get_class($this) . "->_loadRemote: getObject", PEAR_LOG_DEBUG);          php::log(get_class($this) . "->_loadRemote: getObject", PEAR_LOG_DEBUG);
507          $result = $this->backend->send('getObject', $this->objectId);          $result = $this->backend->send('getObject', $this->objectId);
508    
509        } elseif ($this->meta[key]) {        } elseif ($this->meta[key]) {
510          if (!$this->meta[command]) {          if (!$this->meta[command]) {
511            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);
512            return;            return;
513          }          }
514          /*          /*
515          if (!$this->meta[query]) {          if (!$this->meta[query]) {
516            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);
517            return;            return;
518          }          }
519          */          */
520          //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);
521          //print Dumper(array($this->meta[command], $this->meta[query]));          //print Dumper(array($this->meta[command], $this->meta[query]));
522          $result = $this->backend->send($this->meta[command], $this->meta[query]);          $result = $this->backend->send($this->meta[command], $this->meta[query]);
523                    
# Line 560  function draw_error_box($status) { Line 566  function draw_error_box($status) {
566    $statusbox->add( html_span('boxlabel_yellow', "Connected:"), $status[connected], html_br() );    $statusbox->add( html_span('boxlabel_yellow', "Connected:"), $status[connected], html_br() );
567    $statusbox->add( html_span('boxlabel_yellow', "RPCSESSID:"), $status[RPCSESSID], html_br() );    $statusbox->add( html_span('boxlabel_yellow', "RPCSESSID:"), $status[RPCSESSID], html_br() );
568    foreach ($status[errors] as $error) {    foreach ($status[errors] as $error) {
569      $statusbox->add( html_span('boxlabel_yellow', "Error($error[code]):"), $error[message], html_br() );      $msg = html_pre($error[message]);
570        $statusbox->add( html_span('boxlabel_yellow', "Error($error[code]):"), $msg );
571    }    }
572        
573    $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.";
574    logp($message, PEAR_LOG_CRIT);    php::log($message, PEAR_LOG_CRIT);
575    $statusbox->add( html_span('boxlabel_yellow', "Critical:"), $message, html_br() );    $statusbox->add( html_span('boxlabel_yellow', "Critical:"), $message, html_br() );
576    
577    // V1    // V1
# Line 586  function draw_error_box($status) { Line 593  function draw_error_box($status) {
593    
594    
595    function _saveBackend($result) {    function _saveBackend($result) {
596      logp(get_class($this) . "->_saveBackend()");      php::log(get_class($this) . "->_saveBackend()");
597    
598      //$encoder = new TextEncode($result);      //$encoder = new TextEncode($result);
599      //$encoder->toUTF8();      //$encoder->toUTF8();

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

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