18 |
* $Id$ |
* $Id$ |
19 |
* ------------------------------------------------------------------------- |
* ------------------------------------------------------------------------- |
20 |
* $Log$ |
* $Log$ |
21 |
|
* Revision 1.19 2004/06/07 16:56:45 joko |
22 |
|
* enabled caching-layers |
23 |
|
* minor fixes regarding caching |
24 |
|
* |
25 |
|
* Revision 1.18 2004/05/13 19:17:55 jonen |
26 |
|
* + bugfix: utf8 conversion was missing at some backend-calls |
27 |
|
* |
28 |
|
* Revision 1.17 2003/07/14 10:05:23 jonen |
29 |
|
* bugfix: added *needed* function 'getAttributes' |
30 |
|
* |
31 |
|
* Revision 1.16 2003/07/02 13:51:38 jonen |
32 |
|
* removed debug dumper |
33 |
|
* |
34 |
|
* Revision 1.15 2003/04/11 01:32:21 joko |
35 |
|
* renamed logging function |
36 |
|
* |
37 |
|
* Revision 1.14 2003/04/09 02:06:45 joko |
38 |
|
* errormessage now shown preformatted |
39 |
|
* |
40 |
* Revision 1.13 2003/04/04 17:38:03 joko |
* Revision 1.13 2003/04/04 17:38:03 joko |
41 |
* modifications regarding error-/exception-handling and -tracing |
* modifications regarding error-/exception-handling and -tracing |
42 |
* |
* |
285 |
var $backend; |
var $backend; |
286 |
|
|
287 |
function DesignPattern_RemoteProxy($objectId = "", $options = array() ) { |
function DesignPattern_RemoteProxy($objectId = "", $options = array() ) { |
288 |
logp(get_class($this) . "->new()", PEAR_LOG_INFO); |
php::log(get_class($this) . "->new(objectId=$objectId)", PEAR_LOG_INFO); |
289 |
global $proxy; |
global $proxy; |
290 |
|
|
291 |
// 2003-03-05 - modified constructor |
// 2003-03-05 - modified constructor |
349 |
|
|
350 |
|
|
351 |
function load() { |
function load() { |
352 |
logp(get_class($this) . "->load()", PEAR_LOG_INFO); |
php::log(get_class($this) . "->load()", PEAR_LOG_INFO); |
353 |
if (!$this->_loadState()) { |
if (!$this->_loadState()) { |
354 |
if (!$this->_loadProxy()) { |
if (!$this->_loadProxy()) { |
355 |
|
|
406 |
$this->attributes = $data; |
$this->attributes = $data; |
407 |
} |
} |
408 |
|
|
409 |
|
function getAttributes() { |
410 |
|
return $this->attributes; |
411 |
|
} |
412 |
|
|
413 |
function flushProxy() { |
function flushProxy() { |
414 |
connectdb(); |
connectdb(); |
415 |
$sql = "DELETE FROM f_proxy WHERE oid='$this->objectId'"; |
$sql = "DELETE FROM f_proxy WHERE oid='$this->objectId'"; |
425 |
function _loadState() { |
function _loadState() { |
426 |
global $proxy; |
global $proxy; |
427 |
|
|
428 |
|
// just do session-caching if requested |
429 |
|
if (!$this->meta[cache][session]) { return; } |
430 |
|
|
431 |
// trace |
// trace |
432 |
//print Dumper($this); |
//print Dumper($this); |
433 |
|
|
434 |
// debug |
// debug |
435 |
logp(get_class($this) . "->_loadState()"); |
php::log(get_class($this) . "->_loadState()"); |
436 |
|
|
437 |
if ($this->attributes = $proxy[$this->objectId]) { |
if ($this->attributes = $proxy[$this->objectId]) { |
438 |
//print "_loadState:" . dumpVar($this->attributes); |
//print "_loadState:" . dumpVar($this->attributes); |
439 |
$this->meta[decoded] = 1; |
$this->meta[decoded] = 1; |
440 |
// TODO: make a parameter from this (0 deactivates session-layer) |
// TODO: make a parameter from this (0 deactivates session-layer) |
441 |
return 0; |
return 1; |
442 |
} |
} |
443 |
} |
} |
444 |
|
|
445 |
function _saveState() { |
function _saveState() { |
446 |
global $proxy; |
global $proxy; |
447 |
logp(get_class($this) . "->_saveState()"); |
|
448 |
|
// just do session-caching if requested |
449 |
|
if (!$this->meta[cache][session]) { return; } |
450 |
|
|
451 |
|
php::log(get_class($this) . "->_saveState()"); |
452 |
$proxy[$this->objectId] = $this->attributes; |
$proxy[$this->objectId] = $this->attributes; |
453 |
//print "_saveState: " . dumpVar($this->attributes); |
//print "_saveState: " . dumpVar($this->attributes); |
454 |
// TODO: throw exception-message back to user if operation fails |
// TODO: throw exception-message back to user if operation fails |
461 |
|
|
462 |
// trace & debug |
// trace & debug |
463 |
//print Dumper($this); |
//print Dumper($this); |
464 |
logp(get_class($this) . "->_loadProxy()"); |
php::log(get_class($this) . "->_loadProxy()"); |
465 |
|
|
466 |
connectdb(); |
connectdb(); |
467 |
$sql = "SELECT payload FROM f_proxy WHERE oid='$this->objectId'"; |
$sql = "SELECT payload FROM f_proxy WHERE oid='$this->objectId'"; |
470 |
if ($row) { |
if ($row) { |
471 |
$this->payload = $row[payload]; |
$this->payload = $row[payload]; |
472 |
// TODO: make a parameter from this (0 deactivates mysqldb-layer) |
// TODO: make a parameter from this (0 deactivates mysqldb-layer) |
473 |
return 0; |
return 1; |
474 |
} |
} |
475 |
} |
} |
476 |
} |
} |
481 |
// FIXME! |
// FIXME! |
482 |
if (!$this->meta[cache][db]) { return; } |
if (!$this->meta[cache][db]) { return; } |
483 |
|
|
484 |
logp(get_class($this) . "->_saveProxy()"); |
php::log(get_class($this) . "->_saveProxy()"); |
485 |
connectdb(); |
connectdb(); |
486 |
if ($this->payload) { |
if ($this->payload) { |
487 |
//$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'"; |
494 |
} |
} |
495 |
|
|
496 |
function _loadRemote() { |
function _loadRemote() { |
497 |
logp(get_class($this) . "->_loadRemote()"); |
php::log(get_class($this) . "->_loadRemote()"); |
498 |
|
|
499 |
// trace |
// trace |
500 |
//print Dumper($this->meta); |
//print Dumper($this->meta); |
503 |
|
|
504 |
// 1. check backend-handle |
// 1. check backend-handle |
505 |
if (!$this->backend) { |
if (!$this->backend) { |
506 |
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); |
507 |
return; |
return; |
508 |
} |
} |
509 |
|
|
511 |
// check for guid or oid |
// check for guid or oid |
512 |
if ($this->meta[guid]) { |
if ($this->meta[guid]) { |
513 |
if (!$this->objectId) { |
if (!$this->objectId) { |
514 |
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); |
515 |
return; |
return; |
516 |
} |
} |
517 |
if (!$this->meta[classname]) { |
if (!$this->meta[classname]) { |
518 |
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); |
519 |
return; |
return; |
520 |
} |
} |
521 |
logp(get_class($this) . "->_loadRemote: getObjectByGuid", PEAR_LOG_DEBUG); |
php::log(get_class($this) . "->_loadRemote: getObjectByGuid", PEAR_LOG_DEBUG); |
522 |
$args = array( guid => $this->objectId, classname => $this->meta[classname] ); |
$args = array( guid => $this->objectId, classname => $this->meta[classname] ); |
523 |
$result = $this->backend->send('getObjectByGuid', $args ); |
$result = $this->backend->send('getObjectByGuid', $args, array( utf8 => 1) ); |
524 |
|
|
525 |
} elseif ($this->meta[oid]) { |
} elseif ($this->meta[oid]) { |
526 |
if (!$this->objectId) { |
if (!$this->objectId) { |
527 |
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); |
528 |
return; |
return; |
529 |
} |
} |
530 |
logp(get_class($this) . "->_loadRemote: getObject", PEAR_LOG_DEBUG); |
php::log(get_class($this) . "->_loadRemote: getObject", PEAR_LOG_DEBUG); |
531 |
$result = $this->backend->send('getObject', $this->objectId); |
$result = $this->backend->send('getObject', $this->objectId, array( utf8 => 1) ); |
532 |
|
|
533 |
} elseif ($this->meta[key]) { |
} elseif ($this->meta[key]) { |
534 |
if (!$this->meta[command]) { |
if (!$this->meta[command]) { |
535 |
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); |
536 |
return; |
return; |
537 |
} |
} |
538 |
/* |
/* |
539 |
if (!$this->meta[query]) { |
if (!$this->meta[query]) { |
540 |
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); |
541 |
return; |
return; |
542 |
} |
} |
543 |
*/ |
*/ |
544 |
//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); |
545 |
//print Dumper(array($this->meta[command], $this->meta[query])); |
//print Dumper(array($this->meta[command], $this->meta[query])); |
546 |
$result = $this->backend->send($this->meta[command], $this->meta[query]); |
$result = $this->backend->send($this->meta[command], $this->meta[query], array( utf8 => 1) ); |
547 |
|
|
548 |
} |
} |
549 |
|
|
590 |
$statusbox->add( html_span('boxlabel_yellow', "Connected:"), $status[connected], html_br() ); |
$statusbox->add( html_span('boxlabel_yellow', "Connected:"), $status[connected], html_br() ); |
591 |
$statusbox->add( html_span('boxlabel_yellow', "RPCSESSID:"), $status[RPCSESSID], html_br() ); |
$statusbox->add( html_span('boxlabel_yellow', "RPCSESSID:"), $status[RPCSESSID], html_br() ); |
592 |
foreach ($status[errors] as $error) { |
foreach ($status[errors] as $error) { |
593 |
$statusbox->add( html_span('boxlabel_yellow', "Error($error[code]):"), $error[message], html_br() ); |
$msg = html_pre($error[message]); |
594 |
|
$statusbox->add( html_span('boxlabel_yellow', "Error($error[code]):"), $msg ); |
595 |
} |
} |
596 |
|
|
597 |
$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."; |
598 |
logp($message, PEAR_LOG_CRIT); |
php::log($message, PEAR_LOG_CRIT); |
599 |
$statusbox->add( html_span('boxlabel_yellow', "Critical:"), $message, html_br() ); |
$statusbox->add( html_span('boxlabel_yellow', "Critical:"), $message, html_br() ); |
600 |
|
|
601 |
// V1 |
// V1 |
617 |
|
|
618 |
|
|
619 |
function _saveBackend($result) { |
function _saveBackend($result) { |
620 |
logp(get_class($this) . "->_saveBackend()"); |
php::log(get_class($this) . "->_saveBackend()"); |
621 |
|
|
622 |
//$encoder = new TextEncode($result); |
//$encoder = new TextEncode($result); |
623 |
//$encoder->toUTF8(); |
//$encoder->toUTF8(); |
648 |
|
|
649 |
} |
} |
650 |
|
|
|
?> |
|
651 |
|
?> |