| 7 |
* @name DesignPattern::RemoteProxy |
* @name DesignPattern::RemoteProxy |
| 8 |
* |
* |
| 9 |
* |
* |
| 10 |
|
*/ |
| 11 |
|
|
| 12 |
|
|
| 13 |
|
/** |
| 14 |
* <b>Cvs-Log:</b> |
* <b>Cvs-Log:</b> |
| 15 |
* |
* |
| 16 |
* <pre> |
* <pre> |
| 18 |
* $Id$ |
* $Id$ |
| 19 |
* ------------------------------------------------------------------------- |
* ------------------------------------------------------------------------- |
| 20 |
* $Log$ |
* $Log$ |
| 21 |
|
* Revision 1.14 2003/04/09 02:06:45 joko |
| 22 |
|
* errormessage now shown preformatted |
| 23 |
|
* |
| 24 |
|
* Revision 1.13 2003/04/04 17:38:03 joko |
| 25 |
|
* modifications regarding error-/exception-handling and -tracing |
| 26 |
|
* |
| 27 |
|
* Revision 1.12 2003/03/29 08:01:21 joko |
| 28 |
|
* modified ErrorBoxing |
| 29 |
|
* |
| 30 |
|
* Revision 1.11 2003/03/28 06:44:51 joko |
| 31 |
|
* VERBOSE mode |
| 32 |
|
* |
| 33 |
|
* Revision 1.10 2003/03/28 03:05:54 joko |
| 34 |
|
* more fancy debugging-output |
| 35 |
|
* |
| 36 |
|
* Revision 1.9 2003/03/10 23:05:25 joko |
| 37 |
|
* + fixed metadata for phpDocumentor |
| 38 |
|
* |
| 39 |
* Revision 1.8 2003/03/10 22:31:56 joko |
* Revision 1.8 2003/03/10 22:31:56 joko |
| 40 |
* + fixed metadata for phpDocumentor |
* + fixed metadata for phpDocumentor |
| 41 |
* |
* |
| 491 |
logp(get_class($this) . "->_loadRemote: argument 'guid' requires 'classname'", PEAR_LOG_WARNING); |
logp(get_class($this) . "->_loadRemote: argument 'guid' requires 'classname'", PEAR_LOG_WARNING); |
| 492 |
return; |
return; |
| 493 |
} |
} |
| 494 |
|
logp(get_class($this) . "->_loadRemote: getObjectByGuid", PEAR_LOG_DEBUG); |
| 495 |
$args = array( guid => $this->objectId, classname => $this->meta[classname] ); |
$args = array( guid => $this->objectId, classname => $this->meta[classname] ); |
| 496 |
$result = $this->backend->send('getObjectByGuid', $args ); |
$result = $this->backend->send('getObjectByGuid', $args ); |
| 497 |
|
|
| 500 |
logp(get_class($this) . "->_loadRemote: argument 'oid' requires valid objectId", PEAR_LOG_WARNING); |
logp(get_class($this) . "->_loadRemote: argument 'oid' requires valid objectId", PEAR_LOG_WARNING); |
| 501 |
return; |
return; |
| 502 |
} |
} |
| 503 |
|
logp(get_class($this) . "->_loadRemote: getObject", PEAR_LOG_DEBUG); |
| 504 |
$result = $this->backend->send('getObject', $this->objectId); |
$result = $this->backend->send('getObject', $this->objectId); |
| 505 |
|
|
| 506 |
} elseif ($this->meta[key]) { |
} elseif ($this->meta[key]) { |
| 514 |
return; |
return; |
| 515 |
} |
} |
| 516 |
*/ |
*/ |
| 517 |
|
//logp(get_class($this) . "->_loadRemote: $this->meta[command](" . join(' ', $this->meta[query]) . ")", PEAR_LOG_DEBUG); |
| 518 |
|
//print Dumper(array($this->meta[command], $this->meta[query])); |
| 519 |
$result = $this->backend->send($this->meta[command], $this->meta[query]); |
$result = $this->backend->send($this->meta[command], $this->meta[query]); |
| 520 |
|
|
| 521 |
} |
} |
| 522 |
|
|
| 523 |
|
//print "result: " . dumpVar($result) . "<br>"; |
| 524 |
|
|
| 525 |
|
$status = $this->backend->status(); |
| 526 |
|
//print Dumper($status); |
| 527 |
|
|
| 528 |
if ($result) { |
$good = is_array($result) && sizeof($result) && $status[connected]; |
| 529 |
//print "result: " . dumpVar($result) . "<br>"; |
|
| 530 |
if (count($result) == 0) { return; } |
if ($good) { |
| 531 |
|
|
| 532 |
// FIXME: this is dangerous! |
// FIXME: this is dangerous! |
| 533 |
|
/* |
| 534 |
if ($_GET[debug]) { |
if ($_GET[debug]) { |
| 535 |
print Dumper($result); |
print Dumper($result); |
| 536 |
} |
} |
| 537 |
|
*/ |
| 538 |
|
|
| 539 |
$this->payload = serialize($result); |
$this->payload = serialize($result); |
| 540 |
// ----- move this to _encode some times |
// ----- move this to _encode some times |
| 542 |
$this->_saveProxy(); |
$this->_saveProxy(); |
| 543 |
//print "oid: $this->objectId<br>"; |
//print "oid: $this->objectId<br>"; |
| 544 |
$this->flushState(); |
$this->flushState(); |
| 545 |
|
|
| 546 |
} else { |
} else { |
| 547 |
//print "Error in _loadRemote!!!<br>"; |
|
| 548 |
logp(get_class($this) . "->_loadRemote: error while trying to talk to remote side", PEAR_LOG_CRIT); |
if (constants::get('APP_MODE_DEBUG')) { |
| 549 |
|
$this->draw_error_box($status); |
| 550 |
|
} else { |
| 551 |
|
php::maintenance('rpc', array( status => $status ) ); |
| 552 |
|
} |
| 553 |
|
|
| 554 |
} |
} |
| 555 |
|
|
| 556 |
} |
} |
| 557 |
|
|
| 558 |
|
function draw_error_box($status) { |
| 559 |
|
$style = html_style("text/css", '.boxlabel_yellow { color: yellow; font-weight:bold; }'); |
| 560 |
|
$statusbox = html_div(); |
| 561 |
|
$statusbox->set_style('background: red; border: 2px black groove; width:640px; padding:10px; margin:40px;'); |
| 562 |
|
$statusbox->add( html_span('boxlabel_yellow', "Method:"), get_class($this) . "->_loadRemote", html_br() ); |
| 563 |
|
$statusbox->add( html_span('boxlabel_yellow', "Connected:"), $status[connected], html_br() ); |
| 564 |
|
$statusbox->add( html_span('boxlabel_yellow', "RPCSESSID:"), $status[RPCSESSID], html_br() ); |
| 565 |
|
foreach ($status[errors] as $error) { |
| 566 |
|
$msg = html_pre($error[message]); |
| 567 |
|
$statusbox->add( html_span('boxlabel_yellow', "Error($error[code]):"), $msg ); |
| 568 |
|
} |
| 569 |
|
|
| 570 |
|
$message = "Error while talking to remote side. Please check wire, socket or api."; |
| 571 |
|
logp($message, PEAR_LOG_CRIT); |
| 572 |
|
$statusbox->add( html_span('boxlabel_yellow', "Critical:"), $message, html_br() ); |
| 573 |
|
|
| 574 |
|
// V1 |
| 575 |
|
/* |
| 576 |
|
if (constants::get('VERBOSE') || constants::get('ERRORS_ONLY')) { |
| 577 |
|
print $style->render(); |
| 578 |
|
print $statusbox->render(); |
| 579 |
|
} else { |
| 580 |
|
foreach ($status[errors] as $error) { |
| 581 |
|
print Dumper($error); |
| 582 |
|
} |
| 583 |
|
} |
| 584 |
|
*/ |
| 585 |
|
|
| 586 |
|
// V2 |
| 587 |
|
trace( container($style, $statusbox) ); |
| 588 |
|
|
| 589 |
|
} |
| 590 |
|
|
| 591 |
|
|
| 592 |
function _saveBackend($result) { |
function _saveBackend($result) { |
| 593 |
logp(get_class($this) . "->_saveBackend()"); |
logp(get_class($this) . "->_saveBackend()"); |
| 594 |
|
|