| 18 |
* $Id$ |
* $Id$ |
| 19 |
* ------------------------------------------------------------------------- |
* ------------------------------------------------------------------------- |
| 20 |
* $Log$ |
* $Log$ |
| 21 |
|
* Revision 1.17 2003/07/14 10:05:23 jonen |
| 22 |
|
* bugfix: added *needed* function 'getAttributes' |
| 23 |
|
* |
| 24 |
|
* Revision 1.16 2003/07/02 13:51:38 jonen |
| 25 |
|
* removed debug dumper |
| 26 |
|
* |
| 27 |
|
* Revision 1.15 2003/04/11 01:32:21 joko |
| 28 |
|
* renamed logging function |
| 29 |
|
* |
| 30 |
|
* Revision 1.14 2003/04/09 02:06:45 joko |
| 31 |
|
* errormessage now shown preformatted |
| 32 |
|
* |
| 33 |
* Revision 1.13 2003/04/04 17:38:03 joko |
* Revision 1.13 2003/04/04 17:38:03 joko |
| 34 |
* modifications regarding error-/exception-handling and -tracing |
* modifications regarding error-/exception-handling and -tracing |
| 35 |
* |
* |
| 278 |
var $backend; |
var $backend; |
| 279 |
|
|
| 280 |
function DesignPattern_RemoteProxy($objectId = "", $options = array() ) { |
function DesignPattern_RemoteProxy($objectId = "", $options = array() ) { |
| 281 |
logp(get_class($this) . "->new()", PEAR_LOG_INFO); |
php::log(get_class($this) . "->new()", PEAR_LOG_INFO); |
| 282 |
global $proxy; |
global $proxy; |
| 283 |
|
|
| 284 |
// 2003-03-05 - modified constructor |
// 2003-03-05 - modified constructor |
| 342 |
|
|
| 343 |
|
|
| 344 |
function load() { |
function load() { |
| 345 |
logp(get_class($this) . "->load()", PEAR_LOG_INFO); |
php::log(get_class($this) . "->load()", PEAR_LOG_INFO); |
| 346 |
if (!$this->_loadState()) { |
if (!$this->_loadState()) { |
| 347 |
if (!$this->_loadProxy()) { |
if (!$this->_loadProxy()) { |
| 348 |
|
|
| 399 |
$this->attributes = $data; |
$this->attributes = $data; |
| 400 |
} |
} |
| 401 |
|
|
| 402 |
|
function getAttributes() { |
| 403 |
|
return $this->attributes; |
| 404 |
|
} |
| 405 |
|
|
| 406 |
function flushProxy() { |
function flushProxy() { |
| 407 |
connectdb(); |
connectdb(); |
| 408 |
$sql = "DELETE FROM f_proxy WHERE oid='$this->objectId'"; |
$sql = "DELETE FROM f_proxy WHERE oid='$this->objectId'"; |
| 422 |
//print Dumper($this); |
//print Dumper($this); |
| 423 |
|
|
| 424 |
// debug |
// debug |
| 425 |
logp(get_class($this) . "->_loadState()"); |
php::log(get_class($this) . "->_loadState()"); |
| 426 |
|
|
| 427 |
if ($this->attributes = $proxy[$this->objectId]) { |
if ($this->attributes = $proxy[$this->objectId]) { |
| 428 |
//print "_loadState:" . dumpVar($this->attributes); |
//print "_loadState:" . dumpVar($this->attributes); |
| 434 |
|
|
| 435 |
function _saveState() { |
function _saveState() { |
| 436 |
global $proxy; |
global $proxy; |
| 437 |
logp(get_class($this) . "->_saveState()"); |
php::log(get_class($this) . "->_saveState()"); |
| 438 |
$proxy[$this->objectId] = $this->attributes; |
$proxy[$this->objectId] = $this->attributes; |
| 439 |
//print "_saveState: " . dumpVar($this->attributes); |
//print "_saveState: " . dumpVar($this->attributes); |
| 440 |
// TODO: throw exception-message back to user if operation fails |
// TODO: throw exception-message back to user if operation fails |
| 447 |
|
|
| 448 |
// trace & debug |
// trace & debug |
| 449 |
//print Dumper($this); |
//print Dumper($this); |
| 450 |
logp(get_class($this) . "->_loadProxy()"); |
php::log(get_class($this) . "->_loadProxy()"); |
| 451 |
|
|
| 452 |
connectdb(); |
connectdb(); |
| 453 |
$sql = "SELECT payload FROM f_proxy WHERE oid='$this->objectId'"; |
$sql = "SELECT payload FROM f_proxy WHERE oid='$this->objectId'"; |
| 467 |
// FIXME! |
// FIXME! |
| 468 |
if (!$this->meta[cache][db]) { return; } |
if (!$this->meta[cache][db]) { return; } |
| 469 |
|
|
| 470 |
logp(get_class($this) . "->_saveProxy()"); |
php::log(get_class($this) . "->_saveProxy()"); |
| 471 |
connectdb(); |
connectdb(); |
| 472 |
if ($this->payload) { |
if ($this->payload) { |
| 473 |
//$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'"; |
| 480 |
} |
} |
| 481 |
|
|
| 482 |
function _loadRemote() { |
function _loadRemote() { |
| 483 |
logp(get_class($this) . "->_loadRemote()"); |
php::log(get_class($this) . "->_loadRemote()"); |
| 484 |
|
|
| 485 |
// trace |
// trace |
| 486 |
//print Dumper($this->meta); |
//print Dumper($this->meta); |
| 489 |
|
|
| 490 |
// 1. check backend-handle |
// 1. check backend-handle |
| 491 |
if (!$this->backend) { |
if (!$this->backend) { |
| 492 |
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); |
| 493 |
return; |
return; |
| 494 |
} |
} |
| 495 |
|
|
| 497 |
// check for guid or oid |
// check for guid or oid |
| 498 |
if ($this->meta[guid]) { |
if ($this->meta[guid]) { |
| 499 |
if (!$this->objectId) { |
if (!$this->objectId) { |
| 500 |
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); |
| 501 |
return; |
return; |
| 502 |
} |
} |
| 503 |
if (!$this->meta[classname]) { |
if (!$this->meta[classname]) { |
| 504 |
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); |
| 505 |
return; |
return; |
| 506 |
} |
} |
| 507 |
logp(get_class($this) . "->_loadRemote: getObjectByGuid", PEAR_LOG_DEBUG); |
php::log(get_class($this) . "->_loadRemote: getObjectByGuid", PEAR_LOG_DEBUG); |
| 508 |
$args = array( guid => $this->objectId, classname => $this->meta[classname] ); |
$args = array( guid => $this->objectId, classname => $this->meta[classname] ); |
| 509 |
$result = $this->backend->send('getObjectByGuid', $args ); |
$result = $this->backend->send('getObjectByGuid', $args ); |
| 510 |
|
|
| 511 |
} elseif ($this->meta[oid]) { |
} elseif ($this->meta[oid]) { |
| 512 |
if (!$this->objectId) { |
if (!$this->objectId) { |
| 513 |
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); |
| 514 |
return; |
return; |
| 515 |
} |
} |
| 516 |
logp(get_class($this) . "->_loadRemote: getObject", PEAR_LOG_DEBUG); |
php::log(get_class($this) . "->_loadRemote: getObject", PEAR_LOG_DEBUG); |
| 517 |
$result = $this->backend->send('getObject', $this->objectId); |
$result = $this->backend->send('getObject', $this->objectId); |
| 518 |
|
|
| 519 |
} elseif ($this->meta[key]) { |
} elseif ($this->meta[key]) { |
| 520 |
if (!$this->meta[command]) { |
if (!$this->meta[command]) { |
| 521 |
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); |
| 522 |
return; |
return; |
| 523 |
} |
} |
| 524 |
/* |
/* |
| 525 |
if (!$this->meta[query]) { |
if (!$this->meta[query]) { |
| 526 |
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); |
| 527 |
return; |
return; |
| 528 |
} |
} |
| 529 |
*/ |
*/ |
| 530 |
//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); |
| 531 |
//print Dumper(array($this->meta[command], $this->meta[query])); |
//print Dumper(array($this->meta[command], $this->meta[query])); |
| 532 |
$result = $this->backend->send($this->meta[command], $this->meta[query]); |
$result = $this->backend->send($this->meta[command], $this->meta[query]); |
| 533 |
|
|
| 576 |
$statusbox->add( html_span('boxlabel_yellow', "Connected:"), $status[connected], html_br() ); |
$statusbox->add( html_span('boxlabel_yellow', "Connected:"), $status[connected], html_br() ); |
| 577 |
$statusbox->add( html_span('boxlabel_yellow', "RPCSESSID:"), $status[RPCSESSID], html_br() ); |
$statusbox->add( html_span('boxlabel_yellow', "RPCSESSID:"), $status[RPCSESSID], html_br() ); |
| 578 |
foreach ($status[errors] as $error) { |
foreach ($status[errors] as $error) { |
| 579 |
$statusbox->add( html_span('boxlabel_yellow', "Error($error[code]):"), $error[message], html_br() ); |
$msg = html_pre($error[message]); |
| 580 |
|
$statusbox->add( html_span('boxlabel_yellow', "Error($error[code]):"), $msg ); |
| 581 |
} |
} |
| 582 |
|
|
| 583 |
$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."; |
| 584 |
logp($message, PEAR_LOG_CRIT); |
php::log($message, PEAR_LOG_CRIT); |
| 585 |
$statusbox->add( html_span('boxlabel_yellow', "Critical:"), $message, html_br() ); |
$statusbox->add( html_span('boxlabel_yellow', "Critical:"), $message, html_br() ); |
| 586 |
|
|
| 587 |
// V1 |
// V1 |
| 603 |
|
|
| 604 |
|
|
| 605 |
function _saveBackend($result) { |
function _saveBackend($result) { |
| 606 |
logp(get_class($this) . "->_saveBackend()"); |
php::log(get_class($this) . "->_saveBackend()"); |
| 607 |
|
|
| 608 |
//$encoder = new TextEncode($result); |
//$encoder = new TextEncode($result); |
| 609 |
//$encoder->toUTF8(); |
//$encoder->toUTF8(); |
| 634 |
|
|
| 635 |
} |
} |
| 636 |
|
|
|
?> |
|
| 637 |
|
?> |