From 2c5edc7a8b13002ee739ef6e4605560f7ceb8860 Mon Sep 17 00:00:00 2001 From: Ryan Doherty Date: Tue, 11 Jun 2024 10:10:35 -0400 Subject: [PATCH 01/13] Upgrades for Tomcat 9 --- Model/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Model/pom.xml b/Model/pom.xml index ef6e468b5..0c7e9f15e 100644 --- a/Model/pom.xml +++ b/Model/pom.xml @@ -82,7 +82,7 @@ javax.servlet - servlet-api + javax.servlet-api provided @@ -153,7 +153,7 @@ se.jiderhamn.classloader-leak-prevention - classloader-leak-prevention-servlet + classloader-leak-prevention-servlet3 From 3283f4ca1541309bc9f36423b42c6d07cfd505e1 Mon Sep 17 00:00:00 2001 From: Ryan Doherty Date: Fri, 28 Jun 2024 10:33:38 -0400 Subject: [PATCH 02/13] Remove leak preventer- throwing errors that are clogging logs and want to eliminate as a contributor --- Model/pom.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Model/pom.xml b/Model/pom.xml index 0c7e9f15e..0cce40c58 100644 --- a/Model/pom.xml +++ b/Model/pom.xml @@ -151,10 +151,11 @@ + junit From 5ac552bab44c05e6ea7e0fa155dbd1633ab51d64 Mon Sep 17 00:00:00 2001 From: Dan Galdi Date: Thu, 8 Aug 2024 14:29:43 -0400 Subject: [PATCH 03/13] Only close db links for Oracle --- .../org/eupathdb/common/db/EuPathDbDriverInitializer.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Model/src/main/java/org/eupathdb/common/db/EuPathDbDriverInitializer.java b/Model/src/main/java/org/eupathdb/common/db/EuPathDbDriverInitializer.java index f968117d2..7565c9626 100644 --- a/Model/src/main/java/org/eupathdb/common/db/EuPathDbDriverInitializer.java +++ b/Model/src/main/java/org/eupathdb/common/db/EuPathDbDriverInitializer.java @@ -55,8 +55,10 @@ public void closeConnection(Connection connection, ConnectionPoolConfig dbConfig if (dbConfig instanceof ModelConfigAppDB) { connection.setAutoCommit(true); ModelConfigAppDB appDbConfig = (ModelConfigAppDB)dbConfig; - closeDbLink(connection, appDbConfig.getUserDbLink()); - closeDbLink(connection, appDbConfig.getAcctDbLink()); + if (appDbConfig.getPlatformEnum() == SupportedPlatform.ORACLE) { + closeDbLink(connection, appDbConfig.getUserDbLink()); + closeDbLink(connection, appDbConfig.getAcctDbLink()); + } } // set auto-commit back to what it was connection.setAutoCommit(incomingAutoCommit); From 1fb94df28bffac4c5ba3c333485c00e7532fc830 Mon Sep 17 00:00:00 2001 From: Ryan Doherty Date: Tue, 7 Jan 2025 16:55:49 -0500 Subject: [PATCH 04/13] Add required import --- .../java/org/eupathdb/common/db/EuPathDbDriverInitializer.java | 1 + 1 file changed, 1 insertion(+) diff --git a/Model/src/main/java/org/eupathdb/common/db/EuPathDbDriverInitializer.java b/Model/src/main/java/org/eupathdb/common/db/EuPathDbDriverInitializer.java index 7565c9626..21737d84d 100644 --- a/Model/src/main/java/org/eupathdb/common/db/EuPathDbDriverInitializer.java +++ b/Model/src/main/java/org/eupathdb/common/db/EuPathDbDriverInitializer.java @@ -5,6 +5,7 @@ import java.util.Properties; import org.apache.log4j.Logger; +import org.gusdb.fgputil.db.platform.SupportedPlatform; import org.gusdb.fgputil.db.pool.ConnectionPoolConfig; import org.gusdb.fgputil.db.pool.DbDriverInitializer; import org.gusdb.fgputil.db.runner.SQLRunner; From fb160599550c39e3a0e1e7e2debf1b1773e5e1fa Mon Sep 17 00:00:00 2001 From: Ryan Doherty Date: Fri, 10 Jan 2025 17:43:57 -0500 Subject: [PATCH 05/13] Add apicommd dblink lookup for local dev (defaulting to north) --- Model/lib/conifer/roles/conifer/vars/default.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/Model/lib/conifer/roles/conifer/vars/default.yml b/Model/lib/conifer/roles/conifer/vars/default.yml index dbd113d2d..164c5831f 100644 --- a/Model/lib/conifer/roles/conifer/vars/default.yml +++ b/Model/lib/conifer/roles/conifer/vars/default.yml @@ -40,6 +40,7 @@ _userdb_link_map: apicommbetan: betan.login_comment apicommdevs: devs.login_comment apicommdevn: devn.login_comment + apicommd: devn.login_comment apicommlegacys: legacys.login_comment apicommlegacyn: legacyn.login_comment cecomms: ceprods.login_comment From 5003c30d10cfacdf9d538ccc6014971ad205f77b Mon Sep 17 00:00:00 2001 From: Ryan Doherty Date: Fri, 10 Jan 2025 22:47:20 -0500 Subject: [PATCH 06/13] Fix acctdb link for local dev --- Model/lib/conifer/roles/conifer/vars/default.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Model/lib/conifer/roles/conifer/vars/default.yml b/Model/lib/conifer/roles/conifer/vars/default.yml index 164c5831f..176c09c0f 100644 --- a/Model/lib/conifer/roles/conifer/vars/default.yml +++ b/Model/lib/conifer/roles/conifer/vars/default.yml @@ -40,7 +40,7 @@ _userdb_link_map: apicommbetan: betan.login_comment apicommdevs: devs.login_comment apicommdevn: devn.login_comment - apicommd: devn.login_comment + apicommd: devn.login_comment # local dev apicommlegacys: legacys.login_comment apicommlegacyn: legacyn.login_comment cecomms: ceprods.login_comment @@ -52,7 +52,8 @@ _userdb_link_map: _acctdb_link_map: acctdbn: acctdbN.profile acctdbs: acctdbS.profile - acctdb: vm.acctdb # savm + acctdb: acctdbN.profile # local dev +# acctdb: vm.acctdb # savm modelconfig_modelName: =c= WDK model name, e.g. ToxoDB From 800a5f75b87f6c804cedbfaa8370b0901c740604 Mon Sep 17 00:00:00 2001 From: Ryan Doherty Date: Fri, 24 Jan 2025 13:59:29 -0500 Subject: [PATCH 07/13] Add db link reference for cecommd --- .../conifer/roles/conifer/vars/default.yml | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/Model/lib/conifer/roles/conifer/vars/default.yml b/Model/lib/conifer/roles/conifer/vars/default.yml index 176c09c0f..85eb5b733 100644 --- a/Model/lib/conifer/roles/conifer/vars/default.yml +++ b/Model/lib/conifer/roles/conifer/vars/default.yml @@ -34,20 +34,21 @@ _host_frontends: w2: '' _userdb_link_map: - apicomms: prods.login_comment - apicommn: prodn.login_comment - apicommbetas: betas.login_comment - apicommbetan: betan.login_comment - apicommdevs: devs.login_comment - apicommdevn: devn.login_comment - apicommd: devn.login_comment # local dev + apicomms: prods.login_comment + apicommn: prodn.login_comment + apicommbetas: betas.login_comment + apicommbetan: betan.login_comment + apicommdevs: devs.login_comment + apicommdevn: devn.login_comment + apicommd: devn.login_comment # local dev apicommlegacys: legacys.login_comment apicommlegacyn: legacyn.login_comment - cecomms: ceprods.login_comment - cecommn: ceprodn.login_comment - cecommdevs: cedevs.login_comment - cecommdevn: cedevn.login_comment - userdb: vm.userdb + cecomms: ceprods.login_comment + cecommn: ceprodn.login_comment + cecommdevs: cedevs.login_comment + cecommdevn: cedevn.login_comment + cecommd: cedevn.login_comment # local dev + userdb: vm.userdb _acctdb_link_map: acctdbn: acctdbN.profile From 93229d220294279356ee80e07fff23cfd012da58 Mon Sep 17 00:00:00 2001 From: Elizabeth Paige Harper Date: Tue, 4 Mar 2025 19:41:47 -0500 Subject: [PATCH 08/13] dashboard php 8 wip --- Site/dashboard/autoload.php | 16 + Site/dashboard/config/module.php | 103 +++--- Site/dashboard/index.php | 93 ++--- Site/dashboard/json.php | 15 +- Site/dashboard/lib/Configuration.php | 101 ++---- Site/dashboard/lib/JolExecOperation.php | 76 +--- Site/dashboard/lib/JolGenericOperation.php | 53 +-- Site/dashboard/lib/JolListOperation.php | 15 - Site/dashboard/lib/JolOperation.php | 23 +- Site/dashboard/lib/JolQueryResult.php | 67 ++-- Site/dashboard/lib/JolQueryResultItem.php | 32 +- .../dashboard/lib/JolQueryResultItemError.php | 19 +- .../lib/JolQueryResultItemSuccess.php | 25 +- Site/dashboard/lib/JolReadOperation.php | 80 ++--- Site/dashboard/lib/JolRequest.php | 49 ++- Site/dashboard/lib/JolSearchOperation.php | 15 - Site/dashboard/lib/JolWriteOperation.php | 50 ++- Site/dashboard/lib/KeyValue.php | 68 ++-- Site/dashboard/lib/LdapTnsNameResolver.php | 47 +-- Site/dashboard/lib/PrivateAPI.php | 324 ++++++++--------- Site/dashboard/lib/UserAgent.php | 65 ++-- .../{functions.php.inc => lib/functions.php} | 92 ++--- Site/dashboard/lib/modules/ApacheInfo.php | 37 +- Site/dashboard/lib/modules/BuildInfo.php | 24 +- Site/dashboard/lib/modules/CommentConfig.php | 29 +- Site/dashboard/lib/modules/ConnectionPool.php | 39 +- Site/dashboard/lib/modules/DBInstances.php | 36 +- Site/dashboard/lib/modules/Database.php | 54 +-- Site/dashboard/lib/modules/JolModule.php | 45 ++- Site/dashboard/lib/modules/Jvm.php | 40 ++- Site/dashboard/lib/modules/Logger.php | 56 +-- Site/dashboard/lib/modules/ModelConfig.php | 63 ++-- .../dashboard/lib/modules/OpenConnections.php | 57 +-- Site/dashboard/lib/modules/ProxyInfo.php | 68 ++-- Site/dashboard/lib/modules/ServletInfo.php | 61 ++-- Site/dashboard/lib/modules/StageValues.php | 50 +-- .../lib/modules/TuningManagerStatus.php | 38 +- Site/dashboard/lib/modules/WdkCache.php | 52 +-- Site/dashboard/lib/modules/WdkMeta.php | 35 +- Site/dashboard/lib/modules/WdkProperties.php | 22 +- Site/dashboard/lib/modules/Webapp.php | 164 +++++---- Site/dashboard/lib/modules/WorkflowStatus.php | 36 +- Site/dashboard/lib/xml/functions.php | 41 +++ Site/dashboard/lib/xmlfunctions.inc | 63 ---- Site/dashboard/test/Memory.php | 53 ++- Site/dashboard/test/jmx_bridge_query_test.php | 121 ------- Site/dashboard/test/jol_request_test.php | 181 +++++----- Site/dashboard/test/memory_class_test.php | 19 +- Site/dashboard/view/about.php | 9 +- Site/dashboard/view/apacheInfo.php | 65 ++-- Site/dashboard/view/buildInfo.php | 224 +++++------- Site/dashboard/view/configurationInfo.php | 68 ++-- Site/dashboard/view/databaseInfo.php | 336 +++++++++--------- Site/dashboard/view/dbConnectionPool.php | 198 ++++++----- .../view/dumpDbConnectionStatsToLog.php | 9 +- Site/dashboard/view/jslint.php | 73 ++-- Site/dashboard/view/logger.php | 16 +- Site/dashboard/view/proxyInfo.php | 24 +- Site/dashboard/view/reloadWebapp.php | 14 +- Site/dashboard/view/services.php | 138 +++---- Site/dashboard/view/stateInfo.php | 84 +++-- Site/dashboard/view/tomcatInfo.php | 113 +++--- Site/dashboard/view/wdkCacheTableCount.php | 8 +- Site/dashboard/view/wdkIsCaching.php | 17 +- Site/dashboard/xml.php | 37 +- 65 files changed, 1929 insertions(+), 2416 deletions(-) create mode 100644 Site/dashboard/autoload.php delete mode 100644 Site/dashboard/lib/JolListOperation.php delete mode 100644 Site/dashboard/lib/JolSearchOperation.php rename Site/dashboard/{functions.php.inc => lib/functions.php} (60%) create mode 100644 Site/dashboard/lib/xml/functions.php delete mode 100644 Site/dashboard/lib/xmlfunctions.inc delete mode 100644 Site/dashboard/test/jmx_bridge_query_test.php diff --git a/Site/dashboard/autoload.php b/Site/dashboard/autoload.php new file mode 100644 index 000000000..23ade0e4b --- /dev/null +++ b/Site/dashboard/autoload.php @@ -0,0 +1,16 @@ + array( - 'module' => "view/databaseInfo.php", - 'tab' => 1), - 'Database Connection Pool' => array( - 'module' => "view/dbConnectionPool.php", - 'tab' => 0), - 'WDK State' => array( - 'module' => "view/stateInfo.php", - 'tab' => 1), - 'Configuration' => array( - 'module' => "view/configurationInfo.php", - 'tab' => 1), - 'Tomcat' => array( - 'module' => "view/tomcatInfo.php", - 'tab' => 1), - 'Apache' => array( - 'module' => "view/apacheInfo.php", - 'tab' => 1), - 'Proxy' => array( - 'module' => "view/proxyInfo.php", - 'tab' => 1), - 'Build' => array( - 'module' => "view/buildInfo.php", - 'tab' => 1), - 'Announcements' => array( - 'module' => "/cgi-bin/admin/messageConsole.pl", - 'tab' => 1), - 'Performance' => array( - 'module' => 'view/performance.php', - 'tab' => 1), - 'Services' => array( - 'module' => 'view/services.php', - 'tab' => 1), - 'JSLint' => array( - 'module' => 'view/jslint.php', - 'tab' => 0), - 'Logger' => array( - 'module' => "view/logger.php", - 'tab' => 0), - 'About' => array( - 'module' => "view/about.php", - 'tab' => 0), - ); -?> +$pageMap = [ + 'Databases' => [ + 'module' => "view/databaseInfo.php", + 'tab' => 1 + ], + 'Database Connection Pool' => [ + 'module' => "view/dbConnectionPool.php", + 'tab' => 0 + ], + 'WDK State' => [ + 'module' => "view/stateInfo.php", + 'tab' => 1 + ], + 'Configuration' => [ + 'module' => "view/configurationInfo.php", + 'tab' => 1 + ], + 'Tomcat' => [ + 'module' => "view/tomcatInfo.php", + 'tab' => 1 + ], + 'Apache' => [ + 'module' => "view/apacheInfo.php", + 'tab' => 1 + ], + 'Proxy' => [ + 'module' => "view/proxyInfo.php", + 'tab' => 1 + ], + 'Build' => [ + 'module' => "view/buildInfo.php", + 'tab' => 1 + ], + 'Announcements' => [ + 'module' => "/cgi-bin/admin/messageConsole.pl", + 'tab' => 1 + ], + 'Performance' => [ + 'module' => 'view/performance.php', + 'tab' => 1 + ], + 'Services' => [ + 'module' => 'view/services.php', + 'tab' => 1 + ], + 'JSLint' => [ + 'module' => 'view/jslint.php', + 'tab' => 0 + ], + 'Logger' => [ + 'module' => "view/logger.php", + 'tab' => 0 + ], + 'About' => [ + 'module' => "view/about.php", + 'tab' => 0 + ], +]; diff --git a/Site/dashboard/index.php b/Site/dashboard/index.php index ea8aa7672..399a3feac 100644 --- a/Site/dashboard/index.php +++ b/Site/dashboard/index.php @@ -1,79 +1,84 @@ - - - - + + + - -
    - $value) { - if ( exclude_this($pageMap, $key) ) { continue; } - if ( ! $pageMap[$key]['tab']) { continue; } - if ( $key == 'Proxy' && !isset($headers['Via']) ) { continue; } - $active = ($key == $page) ? "class='active'" : ''; - print "
  • $key
  • \n"; - } - ?> -
- -
- - $value) { + if (exclude_this($pageMap, $key)) + continue; + if (!$pageMap[$key]['tab']) + continue; -if (!$pageMap[$page]) { + if ($key == 'Proxy' && !isset($headers['Via'])) + continue; + $active = ($key == $page) ? "class='active'" : ''; + print "
  • $key
  • \n"; + } + ?> + +
    + - - + } + ?> +
    - diff --git a/Site/dashboard/json.php b/Site/dashboard/json.php index 6ed00f4dc..5316cdf7a 100644 --- a/Site/dashboard/json.php +++ b/Site/dashboard/json.php @@ -1,15 +1,8 @@ to_json(); -?> +print (new PrivateAPI())->to_json(); diff --git a/Site/dashboard/lib/Configuration.php b/Site/dashboard/lib/Configuration.php index 273f86381..bc52e74ee 100644 --- a/Site/dashboard/lib/Configuration.php +++ b/Site/dashboard/lib/Configuration.php @@ -1,38 +1,31 @@ - */ + private array $conf_ar; - /** @var string */ - private $global_conf_file_path; + private string $global_conf_file_path; - /** @var string */ - private $local_conf_file_path; + private string $local_conf_file_path; public function __construct() { $this->global_conf_file_path = dirname(__FILE__) . '/../config/config.ini'; $this->local_conf_file_path = dirname(__FILE__) . '/../config/config.local.ini'; - $g_conf_ar = array(); - $l_conf_ar = array(); + $g_conf_ar = []; + $l_conf_ar = []; if (file_exists($this->global_conf_file_path)) { $g_conf_ar = parse_ini_file($this->global_conf_file_path); @@ -52,46 +45,23 @@ public function __construct() { } } - $partial_conf_ar = array_merge($g_conf_ar, $l_conf_ar); $this->add_http_port_value($partial_conf_ar); $this->add_webapp_value($partial_conf_ar); - $partial_conf_ar{'jol_base_url'} = 'http://' . - $partial_conf_ar{'jmx_bridge_host'} . ':' . - $partial_conf_ar{'http_port'} . '/' . - $partial_conf_ar{'jmx_bridge_context'} . '/'; + $partial_conf_ar['jol_base_url'] = 'http://' . + $partial_conf_ar['jmx_bridge_host'] . ':' . + $partial_conf_ar['http_port'] . '/' . + $partial_conf_ar['jmx_bridge_context'] . '/'; $this->conf_ar = $partial_conf_ar; } - /** - * Static initializer so one can chain methods at construction time - * $c = Configuration::init()->get_configuration(); - * - * @return Configuration - */ - static public function init() { - return new self(); - } - - /** - * Return the full configuration array - * - * @return array - */ - public function get_configuration() { - return $this->conf_ar; - } - /** * Return value for given configuration key - * - * @return string - * @param string configuration key */ - public function get($key) { + public function get(string $key): ?string { if (!array_key_exists($key, $this->conf_ar)) { return null; } @@ -101,49 +71,46 @@ public function get($key) { /** * Add the http port to the configuration array * - * @param array Array of configuration key/value pairs. - * @return void + * @param array $partial_conf_ar Array of configuration key/value pairs. */ - private function add_http_port_value(&$partial_conf_ar) { + private function add_http_port_value(array &$partial_conf_ar): void { - $kv = new KeyValue($partial_conf_ar{'worker_properties_file'}); + $kv = new KeyValue($partial_conf_ar['worker_properties_file']); /** construct the key name from template to lookup the http - port from workers.properties * */ + * port from workers.properties * */ // template is custom.%TOMCAT_INSTANCE%.http_port - $http_key_tmpl = $partial_conf_ar{'worker_properties_http_var_tmpl'}; + $http_key_tmpl = $partial_conf_ar['worker_properties_http_var_tmpl']; if (array_key_exists('SERVER_NAME', $_SERVER)) { // worker name, e.g. TonkaDB - $worker = $_SERVER{$partial_conf_ar{'worker_env_var_name'}}; + $worker = $_SERVER[$partial_conf_ar['worker_env_var_name']]; } else { // maybe running from command line, use value in config file - $worker = $partial_conf_ar{'tomcat_instance_for_testing'}; + $worker = $partial_conf_ar['tomcat_instance_for_testing']; } - // key after macro substition, key is custom.TonkaDB.http_port + // key after macro substitution, key is custom.TonkaDB.http_port $http_port_key_name = str_replace('%TOMCAT_INSTANCE%', $worker, $http_key_tmpl); - $partial_conf_ar{'http_port'} = $kv->get($http_port_key_name); + $partial_conf_ar['http_port'] = $kv->get($http_port_key_name); } /** * Add the webapp to the configuration array * - * @param array Array of configuration key/value pairs. + * @param array $partial_conf_ar Array of configuration key/value pairs. + * * @return void */ - private function add_webapp_value(&$partial_conf_ar) { + private function add_webapp_value(array &$partial_conf_ar): void { if (array_key_exists('SERVER_NAME', $_SERVER)) { - $context_path = $_SERVER{$partial_conf_ar{'ctx_path_env_var_name'}}; + $context_path = $_SERVER[$partial_conf_ar['ctx_path_env_var_name']]; } else { // maybe running from command line, use value in config file - $context_path = $partial_conf_ar{'tomcat_webapp_for_testing'}; + $context_path = $partial_conf_ar['tomcat_webapp_for_testing']; } - $partial_conf_ar{'context_path'} = $context_path; + $partial_conf_ar['context_path'] = $context_path; } - } - -?> diff --git a/Site/dashboard/lib/JolExecOperation.php b/Site/dashboard/lib/JolExecOperation.php index cdaf22c07..2b7475255 100644 --- a/Site/dashboard/lib/JolExecOperation.php +++ b/Site/dashboard/lib/JolExecOperation.php @@ -1,6 +1,4 @@ -add_operation($op); * - * - * $mbean and $operation properties must be set - * - * @package JMX - * @subpackage Request */ class JolExecOperation extends JolOperation { - - /** @var string */ - private $mbean; - - /** @var string */ - private $operation; - - /** @var array|string */ - private $arguments; - /** * Initializes the Operation object. * * Initialization minimally requires populating $http_post_array. - * */ - protected function init(array $args = null) { - $this->http_post_array{'type'} = 'exec'; + protected function init(?array $args = null): void { + $this->http_post_array['type'] = 'exec'; if (!isset($args)) return; - $this->http_post_array{'mbean'} - = array_key_exists('mbean', $args) ? $args{'mbean'} : null; - $this->http_post_array{'operation'} - = array_key_exists('operation', $args) ? $args{'operation'} : null; - $this->http_post_array{'arguments'} - = array_key_exists('arguments', $args) ? $args{'arguments'} : null; - } - - /** - * MBean's ObjectName - * - * For example, - * java.util.logging:type=Logging - * - * Can be a pattern. See Jolokia documentation. - * - * @param string $mbean - */ - public function set_mbean($mbean) { - $this->mbean = $mbean; - } - - /** - * MBean attribute - * - * Attribute name to read or an array containing a list attributes - * to read. If no attribute is given, then all attributes are read. - * - * @param string $attribute - */ - public function set_attribute($attribute) { - $this->attribute = $attribute; + $this->http_post_array['mbean'] = array_key_exists('mbean', $args) + ? $args['mbean'] + : null; + $this->http_post_array['operation'] = array_key_exists('operation', $args) + ? $args['operation'] + : null; + $this->http_post_array['arguments'] = array_key_exists('arguments', $args) + ? $args['arguments'] + : null; } /** @@ -104,14 +63,11 @@ public function set_attribute($attribute) { * * @return boolean true if this is a valid object */ - public function is_valid() { + public function is_valid(): bool { $a = $this->http_post_array(); - if (!isset($a{'mbean'}) || !isset($a{'operation'})) { - return FALSE; + if (!isset($a['mbean']) || !isset($a['operation'])) { + return false; } return true; } - } - -?> diff --git a/Site/dashboard/lib/JolGenericOperation.php b/Site/dashboard/lib/JolGenericOperation.php index 95b489d68..699f2e19f 100644 --- a/Site/dashboard/lib/JolGenericOperation.php +++ b/Site/dashboard/lib/JolGenericOperation.php @@ -1,53 +1,2 @@ - - * $op = new JolGenericOperation($array); - * $req = new {@link JolRequest}; - * $req->add_operation($op); - * - * - * @author Mark Heiges - * - * @package JMX - * @subpackage Request - */ -class JolGenericOperation extends JolOperation { - - /** - * Initializes the Operation object. - * - * Input is an array of HTTP POST data that will be rendered to - * json with PHP's json_encode() function. - * - * @param array HTTP POST data - */ - protected function init(array $args = null) { - $this->http_post_array = $args; - } - - /** - * Attempts to determine if the operation object has the required - * POST fields for successful response. - * - * The validation catches common mistakes in initializing the object - * but may miss others. - * - * @return boolean true if this is a valid object - */ - public function is_valid() { - return TRUE; - } - -} - -?> diff --git a/Site/dashboard/lib/JolListOperation.php b/Site/dashboard/lib/JolListOperation.php deleted file mode 100644 index 5e2e70a20..000000000 --- a/Site/dashboard/lib/JolListOperation.php +++ /dev/null @@ -1,15 +0,0 @@ - diff --git a/Site/dashboard/lib/JolOperation.php b/Site/dashboard/lib/JolOperation.php index 702fa2a67..e11b571a0 100644 --- a/Site/dashboard/lib/JolOperation.php +++ b/Site/dashboard/lib/JolOperation.php @@ -1,5 +1,7 @@ http_post_array = array(); + public function __construct(?array $args = null) { + $this->http_post_array = []; $this->init($args); } @@ -37,7 +37,7 @@ public function __construct($args = null) { * * @return array */ - public function http_post_array() { + public function http_post_array(): array { return $this->http_post_array; } @@ -45,9 +45,8 @@ public function http_post_array() { * Initializes the Operation object. * * Initialization minimally requires populating $http_post_array. - * */ - abstract protected function init(array $args = null); + abstract protected function init(array $args = null): void; /** * Attempts to determine if the operation object has the required @@ -58,7 +57,5 @@ abstract protected function init(array $args = null); * * @return boolean true if this is a valid object */ - abstract public function is_valid(); + abstract public function is_valid(): bool; } - -?> diff --git a/Site/dashboard/lib/JolQueryResult.php b/Site/dashboard/lib/JolQueryResult.php index 1c4be4b58..884881ab5 100644 --- a/Site/dashboard/lib/JolQueryResult.php +++ b/Site/dashboard/lib/JolQueryResult.php @@ -1,31 +1,29 @@ - */ + private array $result_array = []; + + /** @var array */ + private array $error_array = []; + + public function __construct(string $json_result) { if (empty($json_result)) { error_log('json_result is empty. ' . ' at ' . __CLASS__ . ' line ' . __LINE__); //throw new Exception("json result is empty"); return; } - $this->position = 0; $this->set_json_result($json_result); } - public function set_json_result($json_result) { + public function set_json_result(string $json_result): void { $this->json_result = $json_result; $ar_result = json_decode($this->json_result, true); @@ -34,49 +32,48 @@ public function set_json_result($json_result) { return; } // normalize single entity responses into an array - // so they are consistent with bulk query responsess + // so they are consistent with bulk query responses if (array_key_exists('status', $ar_result)) { - $ar_result = array($ar_result); + $ar_result = [$ar_result]; } foreach ($ar_result as $result) { - if (isset($result) && $result{'status'} == '200') { - array_push($this->result_array, new JolQueryResultItemSuccess($result)); + if (isset($result) && $result['status'] == '200') { + $this->result_array[] = new JolQueryResultItemSuccess($result); } else { $error = new JolQueryResultItemError($result); - array_push($this->result_array, $error); - $this->has_error = TRUE; - array_push($this->error_array, $error); + $this->result_array[] = $error; + $this->has_error = true; + $this->error_array[] = $error; } } } - public function has_error() { + public function has_error(): bool { return $this->has_error; } - public function is_success() { + public function is_success(): bool { return !$this->has_error; } - public function get_errors() { + public function get_errors(): array { return $this->error_array; } - public function get_json_result() { + public function get_json_result(): string { return $this->json_result; } - public function get_result_array() { + public function get_result_array(): array { return $this->result_array; } - public function getIterator() { + public function getIterator(): ArrayIterator { return new ArrayIterator($this->result_array); } - /** ArrayAccess methods * */ - public function offsetSet($offset, $value) { + public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->result_array[] = $value; } else { @@ -84,17 +81,15 @@ public function offsetSet($offset, $value) { } } - public function offsetExists($offset) { + public function offsetExists($offset): bool { return isset($this->result_array[$offset]); } - public function offsetUnset($offset) { + public function offsetUnset($offset): void { unset($this->result_array[$offset]); } - public function offsetGet($offset) { - return isset($this->result_array[$offset]) ? $this->result_array[$offset] : null; + public function offsetGet($offset): ?JolQueryResultItem { + return $this->result_array[$offset] ?? null; } - } -?> diff --git a/Site/dashboard/lib/JolQueryResultItem.php b/Site/dashboard/lib/JolQueryResultItem.php index 3f83b377f..96ef830b0 100644 --- a/Site/dashboard/lib/JolQueryResultItem.php +++ b/Site/dashboard/lib/JolQueryResultItem.php @@ -1,30 +1,29 @@ - - * @package JMX - * @subpackage Response **/ abstract class JolQueryResultItem { - protected $item; - protected $is_error; + protected array $item; - public function __construct($item) { + protected bool $is_error; + + public function __construct(array $item) { $this->item = $item; } - public function is_error() { + public function is_error(): bool { return $this->is_error; } - public function is_success() { + public function is_success(): bool { return !$this->is_error; } - protected function set_is_error($is_error) { + protected function set_is_error(bool $is_error): void { $this->is_error = $is_error; } @@ -38,27 +37,22 @@ protected function set_is_error($is_error) { * * @return string json request handled by Jolokia */ - public function request() { - return json_encode($this->item{'request'}); + public function request(): string { + return json_encode($this->item['request']); } /** - * * @return string status code from the Jolokia JSON response object. This * is not the HTTP request status. */ - public function status() { - return $item{'status'}; + public function status(): string { + return $this->item['status']; } /** - * * @return string String representation of the result item. */ - public function to_string() { + public function to_string(): string { return json_encode($this->item); } - } - -?> diff --git a/Site/dashboard/lib/JolQueryResultItemError.php b/Site/dashboard/lib/JolQueryResultItemError.php index 06fa4e304..4d9865c29 100644 --- a/Site/dashboard/lib/JolQueryResultItemError.php +++ b/Site/dashboard/lib/JolQueryResultItemError.php @@ -1,30 +1,21 @@ -set_is_error(TRUE); + $this->set_is_error(true); } public function error_type() { - return $this->item{'error_type'}; + return $this->item['error_type']; } public function error() { - return $this->item{'error'}; + return $this->item['error']; } public function stacktrace() { - return $this->item{'stacktrace'}; + return $this->item['stacktrace']; } } - -?> diff --git a/Site/dashboard/lib/JolQueryResultItemSuccess.php b/Site/dashboard/lib/JolQueryResultItemSuccess.php index a55acc67f..590ea9fcf 100644 --- a/Site/dashboard/lib/JolQueryResultItemSuccess.php +++ b/Site/dashboard/lib/JolQueryResultItemSuccess.php @@ -1,37 +1,26 @@ -set_is_error(FALSE); + $this->set_is_error(false); } /** - * * @return string The epoch time when the request was handled by Jolokia. */ - public function timestamp() { - return $this->item{'timestamp'}; + public function timestamp(): string { + return $this->item['timestamp']; } /** - * * @return mixed The value returned from a single request. * The returned data structure (array, string, map) depends on * the output of PHP's json_decode() function for the given json * string. */ - public function value() { - return $this->item{'value'}; + public function value(): mixed { + return $this->item['value']; } } - -?> diff --git a/Site/dashboard/lib/JolReadOperation.php b/Site/dashboard/lib/JolReadOperation.php index 9c483d45f..6fbe44306 100644 --- a/Site/dashboard/lib/JolReadOperation.php +++ b/Site/dashboard/lib/JolReadOperation.php @@ -1,6 +1,4 @@ -http_post_array{'type'} = 'read'; + protected function init(?array $args = null): void { + $this->http_post_array['type'] = 'read'; if (!isset($args)) return; - $this->http_post_array{'mbean'} - = array_key_exists('mbean', $args) ? $args{'mbean'} : null; - $this->http_post_array{'attribute'} - = array_key_exists('attribute', $args) ? $args{'attribute'} : null; - $this->http_post_array{'path'} - = array_key_exists('path', $args) ? $args{'path'} : null; - } - - public function set_mbean($mbean) { - $this->mbean = $mbean; - } - - /** - * MBean attribute - * - * Attribute name to read or an array containing a list attributes - * to read. If no attribute is given, then all attributes are read. - * - * @param string $attribute - */ - public function set_attribute($attribute) { - $this->attribute = $attribute; - } - - /** - * Inner path for accessing the value of a complex value - * - * @param string $path - */ - public function set_path($path) { - $this->path = $path; + $this->http_post_array['mbean'] = array_key_exists('mbean', $args) + ? $args['mbean'] + : null; + $this->http_post_array['attribute'] = array_key_exists('attribute', $args) + ? $args['attribute'] + : null; + $this->http_post_array['path'] = array_key_exists('path', $args) + ? $args['path'] + : null; } /** @@ -101,27 +71,27 @@ public function set_path($path) { * * @return boolean true if this is a valid object */ - public function is_valid() { + public function is_valid(): bool { $a = $this->http_post_array(); - if (!isset($a{'mbean'})) { - return FALSE; + + if (!isset($a['mbean'])) { + return false; } - if (isset($a{'path'}) && !isset($a{'attribute'})) { - return FALSE; + + if (isset($a['path']) && !isset($a['attribute'])) { + return false; } - return TRUE; + + return true; } - public function __toString() { + public function __toString(): string { $a = $this->http_post_array(); - $string = '{"type":"read","mbean":"' . $a{'mbean'} . '","attribute":"' . join(',', $a{'attribute'}) . '"'; - if (isset($a{'path'})) { - $string .= ',"path":"' . $a{'path'} . '"'; + $string = '{"type":"read","mbean":"' . $a['mbean'] . '","attribute":"' . join(',', $a['attribute']) . '"'; + if (isset($a['path'])) { + $string .= ',"path":"' . $a['path'] . '"'; } $string .= '}'; return $string; } - } - -?> diff --git a/Site/dashboard/lib/JolRequest.php b/Site/dashboard/lib/JolRequest.php index 79aa7d064..6560a4c09 100644 --- a/Site/dashboard/lib/JolRequest.php +++ b/Site/dashboard/lib/JolRequest.php @@ -1,7 +1,6 @@ - */ + private array $operations; /** - * - * @param string base_url e.g. http://localhost:666/jolokia/ + * @param ?string $base_url e.g. http://localhost:666/jolokia/ */ - public function __construct($base_url = null) { - $this->operations = array(); + public function __construct(?string $base_url = null) { + $this->operations = []; $this->set_base_url($base_url); } - public function set_base_url($base_url) { + public function set_base_url(?string $base_url): void { $this->base_url = $base_url; } - public function add_operation($operation) { + public function add_operation(JolOperation $operation) { if ($operation->is_valid()) { - array_push($this->operations, $operation->http_post_array()); + $this->operations[] = $operation->http_post_array(); return; } + throw new Exception("Invalid " . get_class($operation) . " object."); } - public function http_postdata_as_json() { + public function http_postdata_as_json(): bool|string|null { if (count($this->operations) == 0) { return null; } elseif (count($this->operations) == 1) { @@ -48,11 +49,11 @@ public function http_postdata_as_json() { } /** - * Returns an curl command that can be used on the command line for debugging. + * Returns a curl command that can be used on the command line for debugging. * * @return string curl command */ - public function curl_cli_equivalent() { + public function curl_cli_equivalent(): string { return 'curl -d \'' . $this->http_postdata_as_json() . '\' ' . $this->base_url; } @@ -60,16 +61,12 @@ public function curl_cli_equivalent() { * * @return JolQueryResult */ - public function invoke() { - $opts = array( - 'url' => $this->base_url, - 'post_fields' => $this->http_postdata_as_json(), - ); - $ua = new UserAgent($opts); - $this->jmx_query_result = new JolQueryResult($ua->get_content()); - return $this->jmx_query_result; - } + public function invoke(): JolQueryResult { + $opts = [ + 'url' => $this->base_url, + 'post_fields' => $this->http_postdata_as_json(), + ]; + return new JolQueryResult((new UserAgent($opts))->get_content()); + } } - -?> diff --git a/Site/dashboard/lib/JolSearchOperation.php b/Site/dashboard/lib/JolSearchOperation.php deleted file mode 100644 index 1bd982ced..000000000 --- a/Site/dashboard/lib/JolSearchOperation.php +++ /dev/null @@ -1,15 +0,0 @@ - diff --git a/Site/dashboard/lib/JolWriteOperation.php b/Site/dashboard/lib/JolWriteOperation.php index 027f7c0a2..e081a6285 100644 --- a/Site/dashboard/lib/JolWriteOperation.php +++ b/Site/dashboard/lib/JolWriteOperation.php @@ -1,6 +1,4 @@ -add_operation($op); * - * - * @package JMX - * @subpackage Request */ class JolWriteOperation extends JolOperation { - protected function init(array $args = null) { - $this->http_post_array{'type'} = 'write'; + protected function init(array $args = null): void { + $this->http_post_array['type'] = 'write'; if (!isset($args)) return; - $this->http_post_array{'mbean'} - = array_key_exists('mbean', $args) ? $args{'mbean'} : null; - $this->http_post_array{'attribute'} - = array_key_exists('attribute', $args) ? $args{'attribute'} : null; - $this->http_post_array{'value'} - = array_key_exists('value', $args) ? $args{'value'} : null; - $this->http_post_array{'path'} - = array_key_exists('path', $args) ? $args{'path'} : null; + $this->http_post_array['mbean'] = array_key_exists('mbean', $args) + ? $args['mbean'] + : null; + $this->http_post_array['attribute'] = array_key_exists('attribute', $args) + ? $args['attribute'] + : null; + $this->http_post_array['value'] = array_key_exists('value', $args) + ? $args['value'] + : null; + $this->http_post_array['path'] = array_key_exists('path', $args) + ? $args['path'] + : null; } /** @@ -65,20 +64,17 @@ protected function init(array $args = null) { * * @return boolean true if this is a valid object */ - public function is_valid() { + public function is_valid(): bool { $a = $this->http_post_array(); - if (!isset($a{'mbean'})) { - return FALSE; + if (!isset($a['mbean'])) { + return false; } - if (isset($a{'path'}) && !isset($a{'attribute'})) { - return FALSE; + if (isset($a['path']) && !isset($a['attribute'])) { + return false; } - if (!isset($a{'attribute'}) && !isset($a{'value'})) { - return FALSE; + if (!isset($a['attribute']) && !isset($a['value'])) { + return false; } - return TRUE; + return true; } - } - -?> diff --git a/Site/dashboard/lib/KeyValue.php b/Site/dashboard/lib/KeyValue.php index 1aba842f8..09bff321d 100644 --- a/Site/dashboard/lib/KeyValue.php +++ b/Site/dashboard/lib/KeyValue.php @@ -1,66 +1,64 @@ - */ + var array $conf_obj; function __construct($file) { $fh = fopen($file, "rb"); - if (! $fh) { - print "ERROR: parsing $file"; - exit; + if (!$fh) { + print "ERROR: parsing $file"; + exit; } - while (!feof($fh) ) { + while (!feof($fh)) { $line = fgets($fh); - if (preg_match('/^\s*#/', $line)) { continue; } - if (preg_match('/^\s*;/', $line)) { continue; } - if (preg_match('/^\s*$/', $line)) { continue; } - if (!preg_match('/=/', $line)) { continue; } + if (preg_match('/^\s*#/', $line)) { + continue; + } + if (preg_match('/^\s*;/', $line)) { + continue; + } + if (preg_match('/^\s*$/', $line)) { + continue; + } + if (!str_contains($line, '=')) { + continue; + } $kv = explode('=', $line); - if (trim($kv[1]) == '') { continue; } - $this->conf_obj{trim($kv[0])} = trim($kv[1]); + if (trim($kv[1]) == '') { + continue; + } + $this->conf_obj[trim($kv[0])] = trim($kv[1]); } fclose($fh); } /** - Static initializer so one can chain methods at construction time - $c = KeyValue::init()->get_configuration(); - **/ - static public function init() { - return new self(); - } - - /** - Return the full configuration array - **/ - function get_configuration() { + * Return the full configuration array + **/ + function get_configuration(): array { return $this->conf_obj; } /** - Return value for given configuration key - **/ - function get($key) { + * Return value for given configuration key + **/ + function get(string $key): ?string { if (array_key_exists($key, $this->conf_obj)) { return $this->conf_obj[$key]; } return null; } } -?> diff --git a/Site/dashboard/lib/LdapTnsNameResolver.php b/Site/dashboard/lib/LdapTnsNameResolver.php index 509f379c7..5da029fc9 100644 --- a/Site/dashboard/lib/LdapTnsNameResolver.php +++ b/Site/dashboard/lib/LdapTnsNameResolver.php @@ -1,52 +1,53 @@ -dn = "cn=OracleContext,ou=applications,dc=apidb,dc=org"; - $this->attrs = array("cn"); - $this->ldap_url = "ds1.apidb.org ds4.apidb.org"; + private ?string $service_name; + + private string $dn; + + /** @var string[] */ + private array $attrs; + + private string $ldap_url; + + public function __construct(?string $service_name = null) { + $this->service_name = $service_name; + $this->dn = "cn=OracleContext,ou=applications,dc=apidb,dc=org"; + $this->attrs = ["cn"]; + $this->ldap_url = "ds1.apidb.org ds4.apidb.org"; } - /** * Returns an array of aliases from LDAP for given service_name - * - * @return array */ - public function resolve($service_name = null) { - $aliases = array(); + public function resolve(?string $service_name = null): array { + $aliases = []; if ($service_name != null) { - $this->service_name = $service_name; + $this->service_name = $service_name; } $filter = "(orclNetDescString=*" . $this->service_name . "*)"; - $conn = ldap_connect($this->ldap_url, 389); + $conn = ldap_connect($this->ldap_url); ldap_set_option($conn, LDAP_OPT_NETWORK_TIMEOUT, 1); $r = @ldap_bind($conn); - if ( ! $r ) { - error_log( "unable to bind to directory server"); - return $aliases; + if (!$r) { + error_log("unable to bind to directory server"); + return $aliases; } - $sr=ldap_search($conn, $this->dn, $filter, $this->attrs); + $sr = ldap_search($conn, $this->dn, $filter, $this->attrs); $entries = ldap_get_entries($conn, $sr); ldap_close($conn); for ($i = 0; $i < $entries["count"]; $i++) { - array_push($aliases, $entries[$i]["cn"][0]); + $aliases[] = $entries[$i]["cn"][0]; } return $aliases; } } -?> diff --git a/Site/dashboard/lib/PrivateAPI.php b/Site/dashboard/lib/PrivateAPI.php index f500fb9b5..9ca2f395c 100644 --- a/Site/dashboard/lib/PrivateAPI.php +++ b/Site/dashboard/lib/PrivateAPI.php @@ -1,36 +1,41 @@ - - * - * @package Utility - * @subpackage Core */ class PrivateAPI { - var $api_dataset; + var array $api_dataset; + /** + * @throws Exception + */ public function __construct() { $this->init(); } - private function init() { - $this->api_dataset = array(); + /** + * @throws Exception + */ + private function init(): void { + $this->api_dataset = []; $app_database = new Database('APP'); $adb_attr = $app_database->attributes(); @@ -68,67 +73,70 @@ private function init() { $ldap_resolver = new LdapTnsNameResolver(); - $all_data = array( - 'proxy' => array( - 'proxyapp' => $proxy_attr{'proxy_app'}, - 'proxyhost' => $proxy_attr{'proxy_host'}, - 'upstreamhost' => $proxy_attr{'upstream_server'}, - ), - 'wdk' => array( - 'displayname' => $wdk_meta_attr{'DisplayName'}, # wdkModel.getDisplayName() - 'product' => $wdk_meta_attr{'DisplayName'}, # wdkModel.getDisplayName() - 'modelname' => $wdk_meta_attr{'ProjectId'}, # wdkModel.getProjectId() - 'projectid' => $wdk_meta_attr{'ProjectId'}, # wdkModel.getProjectId() - 'modelversion' => $wdk_meta_attr{'ModelVersion'}, # wdkModel.getVersion() - 'buildnumber' => $wdk_meta_attr{'BuildNumber'}, # wdkModel.getBuildNumber() - 'databases' => array( - 'appdb' => array( - 'servicename' => $adb_attr{'service_name'}, - 'instancename' => $adb_attr{'instance_name'}, - 'globalname' => $adb_attr{'global_name'}, - 'dbuniquename' => $adb_attr{'db_unique_name'}, - 'servername' => $adb_attr{'server_name'}, - 'sizeondisk' => $adb_attr{'dbf_gb_on_disk'}, - 'aliases' => $this->array_to_map($ldap_resolver->resolve($adb_attr{'service_name'}), 'alias'), - ), - 'userdb' => array( - 'servicename' => $udb_attr{'service_name'}, - 'instancename' => $udb_attr{'instance_name'}, - 'globalname' => $udb_attr{'global_name'}, - 'servername' => $udb_attr{'server_name'}, - 'sizeondisk' => $udb_attr{'dbf_gb_on_disk'}, - 'aliases' => $this->array_to_map($ldap_resolver->resolve($udb_attr{'service_name'}), 'alias'), - ), - ), - 'querycache' => array( - 'enabled' => ($cache_attr{'WdkIsCaching'}) ? 'true' : 'false', - 'tablecount' => $cache_attr{'cache_table_count'}, - ), - 'modelconfig' => $this->normalize_keys_in_array($model_config_attr), - 'commentconfig' => $this->normalize_keys_in_array($comment_config_attr), - 'modelprop' => $this->normalize_keys_in_array($wdk_properties_attr), - ), - 'tomcat' => array( - 'webapp' => $this->webapp_from_context($webapp_attr{'path'}), - 'webappstarttime' => $webapp_attr{'startTime'}, - 'webappstarttext' => $webapp->uptime_as_text(), - 'instance' => $jvm_attr{'SystemProperties'}{'instance.name'}, - 'instancestarttime' => $jvm_attr{'Uptime'}, - 'instancestarttext' => $jvm->uptime_as_text(), - 'serverinfo' => $servlet_data{'ServerInfo'}, - 'majorversion' => $servletinfo->major_version(), - ), - 'svn' => $this->init_svn_info($build->get_data_map()), - 'vmenv' => $this->virtual_machine_environment_settings( - $wdk_meta_attr, $wdk_properties_attr, $webapp_attr, $adb_attr), - ); + $all_data = [ + 'proxy' => [ + 'proxyapp' => $proxy_attr['proxy_app'], + 'proxyhost' => $proxy_attr['proxy_host'], + 'upstreamhost' => $proxy_attr['upstream_server'], + ], + 'wdk' => [ + 'displayname' => $wdk_meta_attr['DisplayName'], # wdkModel.getDisplayName() + 'product' => $wdk_meta_attr['DisplayName'], # wdkModel.getDisplayName() + 'modelname' => $wdk_meta_attr['ProjectId'], # wdkModel.getProjectId() + 'projectid' => $wdk_meta_attr['ProjectId'], # wdkModel.getProjectId() + 'modelversion' => $wdk_meta_attr['ModelVersion'], # wdkModel.getVersion() + 'buildnumber' => $wdk_meta_attr['BuildNumber'], # wdkModel.getBuildNumber() + 'databases' => [ + 'appdb' => [ + 'servicename' => $adb_attr['service_name'], + 'instancename' => $adb_attr['instance_name'], + 'globalname' => $adb_attr['global_name'], + 'dbuniquename' => $adb_attr['db_unique_name'], + 'servername' => $adb_attr['server_name'], + 'sizeondisk' => $adb_attr['dbf_gb_on_disk'], + 'aliases' => $this->array_to_map($ldap_resolver->resolve($adb_attr['service_name']), 'alias'), + ], + 'userdb' => [ + 'servicename' => $udb_attr['service_name'], + 'instancename' => $udb_attr['instance_name'], + 'globalname' => $udb_attr['global_name'], + 'servername' => $udb_attr['server_name'], + 'sizeondisk' => $udb_attr['dbf_gb_on_disk'], + 'aliases' => $this->array_to_map($ldap_resolver->resolve($udb_attr['service_name']), 'alias'), + ], + ], + 'querycache' => [ + 'enabled' => ($cache_attr['WdkIsCaching']) ? 'true' : 'false', + 'tablecount' => $cache_attr['cache_table_count'], + ], + 'modelconfig' => $this->normalize_keys_in_array($model_config_attr), + 'commentconfig' => $this->normalize_keys_in_array($comment_config_attr), + 'modelprop' => $this->normalize_keys_in_array($wdk_properties_attr), + ], + 'tomcat' => [ + 'webapp' => $this->webapp_from_context($webapp_attr['path']), + 'webappstarttime' => $webapp_attr['startTime'], + 'webappstarttext' => $webapp->uptime_as_text(), + 'instance' => $jvm_attr['SystemProperties']['instance.name'], + 'instancestarttime' => $jvm_attr['Uptime'], + 'instancestarttext' => $jvm->uptime_as_text(), + 'serverinfo' => $servlet_data['ServerInfo'], + 'majorversion' => $servletinfo->major_version(), + ], + 'svn' => $this->init_svn_info($build->get_data_map()), + 'vmenv' => $this->virtual_machine_environment_settings( + $wdk_meta_attr, + $webapp_attr, + $adb_attr + ), + ]; $this->api_dataset = array_merge($this->api_dataset, $all_data); } /** * Split an one dimensional list array into a multidimensional map array using the given key. - * input + * input * array('cryp-inc', 'crypbl2n') * becomes * array( @@ -136,50 +144,26 @@ private function init() { * array( 'alias' => 'crypbl2n') * ) * - * @param $array array to split - * @param $key key value for each array - * @return array - * - */ - private function array_to_map($array, $key) { - $map = array(); - foreach ($array as $v) { - array_push($map, array($key => $v)); - } - return $map; - } - - /** - * Split a string into a multidimensional array using the given key. - * - * array( - * array( 'alias' => 'cryp-inc'), - * array( 'alias' => 'crypbl2n') - * ) + * @param array $array array to split + * @param string $key key value for each array * - * @param $string string to split - * @param $pattern regex to split on - * @param $key key value for each array * @return array * + * @noinspection PhpSameParameterValueInspection */ - private function split_to_map($string, $pattern, $key) { - $map = array(); - $values = preg_split($pattern, $string); - foreach ($values as $v) { - array_push($map, array($key => $v)); + private function array_to_map(array $array, string $key): array { + $map = []; + foreach ($array as $v) { + $map[] = [$key => $v]; } return $map; } /** * lowercase and remove '_' from array keys - * - * @param array - * @return array */ - private function normalize_keys_in_array($in_array) { - $to_array = array(); + private function normalize_keys_in_array(array $in_array): array { + $to_array = []; foreach ($in_array as $k => $v) { if (is_array($v)) { $to_array[strtolower(str_replace('_', '', $k))] = $this->normalize_keys_in_array($v); @@ -193,17 +177,13 @@ private function normalize_keys_in_array($in_array) { /** * Restructures and formats subversion data that was extracted * from the GUS .build.info properties file via the BuildInfo class. - * @see BuildInfo - * - * @param array build data - * @return array */ - private function init_svn_info($build) { - $array = array( - 'locations' => array(), - 'switch' => '', - 'checkout' => '', - ); + private function init_svn_info(array $build): array { + $array = [ + 'locations' => [], + 'switch' => '', + 'checkout' => '', + ]; $switch_stmts = null; $checkout_stmts = null; @@ -211,93 +191,90 @@ private function init_svn_info($build) { foreach ($build as $prop => $data) { if (strpos($prop, '.svn.info')) { $info = $this->svninfo_from_build_data($prop, $data); - if ($info === NULL) { + if ($info === null) { // return empty array so any piping to a shell is a noop return $array; } else { $svnbranch = $info['URL']; $svnproject = $info['Working Directory']; $svnrevision = $info['Revision']; - array_push($array{'locations'}, array('location' => array( - 'remote' => $svnbranch, - 'local' => $svnproject, - 'revision' => $svnrevision - ) - ) - ); + $array['locations'][] = [ + 'location' => [ + 'remote' => $svnbranch, + 'local' => $svnproject, + 'revision' => $svnrevision + ] + ]; $switch_stmts .= "svn switch -r$svnrevision $svnbranch $svnproject;\n"; $checkout_stmts .= "svn checkout -r$svnrevision $svnbranch $svnproject;\n"; } } } - $array{'switch'} = $switch_stmts; - $array{'checkout'} = $checkout_stmts; + $array['switch'] = $switch_stmts; + $array['checkout'] = $checkout_stmts; return $array; } /** * bash shell variable assignments to aid virtual machine setup, e.g. - - PRODUCT=ClinEpiDB - PROJECT=ICEMR - WEBAPP=ce.b2 - HOST=sa.clinenpidb.org - RELEASE_NUMBER=2 - LOGIN=webwww - BUILD_NO=2 -**/ + * + * PRODUCT=ClinEpiDB + * PROJECT=ICEMR + * WEBAPP=ce.b2 + * HOST=sa.clinenpidb.org + * RELEASE_NUMBER=2 + * LOGIN=webwww + * BUILD_NO=2 + **/ private function virtual_machine_environment_settings( - $wdk_meta_attr, $wdk_properties_attr, $webapp_attr, $adb_attr) { + $wdk_meta_attr, + $webapp_attr, + $adb_attr + ): string { - $webapp = $this->webapp_from_context($webapp_attr{'path'}); + $webapp = $this->webapp_from_context($webapp_attr['path']); # webapp names on VMs should be of the form toxo.b12, where '12' is the build # number. So strip any existing extension and add '.b12'. $webapp_base = preg_replace('/\..*/', '', $webapp); - $webapp_for_vm = $webapp_base . '.b' . $wdk_meta_attr{'BuildNumber'}; + $webapp_for_vm = $webapp_base . '.b' . $wdk_meta_attr['BuildNumber']; // e.g. get TLD plasmodb.org from qa.plasmodb.org - preg_match("/[^\.\/]+\.[^\.\/]+$/", $_SERVER['SERVER_NAME'], $matches); + preg_match("/[^.\/]+\.[^.\/]+$/", $_SERVER['SERVER_NAME'], $matches); $tld = @$matches[0]; - $env = ''; - $env .= 'PRODUCT=' . $wdk_meta_attr{'DisplayName'} . "\n"; - $env .= 'PROJECT=' . $wdk_meta_attr{'ProjectId'} . "\n"; + $env = 'PRODUCT=' . $wdk_meta_attr['DisplayName'] . "\n"; + $env .= 'PROJECT=' . $wdk_meta_attr['ProjectId'] . "\n"; $env .= 'HOST=' . 'sa.' . $tld . "\n"; $env .= 'WEBAPP=' . $webapp_for_vm . "\n"; - $env .= 'RELEASE_NUMBER=' . $wdk_meta_attr{'ModelVersion'} . "\n"; - $env .= 'APPDB_LOGIN=' . strtolower($adb_attr{'login'}) . "\n"; - $env .= 'BUILD_NUMBER=' . $wdk_meta_attr{'BuildNumber'} . "\n"; + $env .= 'RELEASE_NUMBER=' . $wdk_meta_attr['ModelVersion'] . "\n"; + $env .= 'APPDB_LOGIN=' . strtolower($adb_attr['login']) . "\n"; + $env .= 'BUILD_NUMBER=' . $wdk_meta_attr['BuildNumber'] . "\n"; + return $env; } // Given '/toxo.b1' return 'toxo.b1' (strip the leading slash) - private function webapp_from_context($context) { + private function webapp_from_context($context): string { $webapp = substr($context, 1); - $webapp = ($webapp == '') ? 'ROOT' : $webapp; - return $webapp; + return ($webapp == '') ? 'ROOT' : $webapp; } - + /** * Returns full data set as XML * - * @return \DomDocument + * @return DOMDocument */ - public function get_xml() { + public function get_xml(): DOMDocument { $xml = new DomDocument('1.0'); $xml->preserveWhiteSpace = false; - $load = $xml->loadXML($this->to_xml($this->api_dataset, 'foos')); + $xml->loadXML($this->to_xml($this->api_dataset, 'foos')); return $xml; } - /** - * - * @param type $array - * @param type $root - * @return string XML - */ - private function to_xml($array, $root) { + /** @noinspection PhpSameParameterValueInspection */ + private function to_xml(array $array, string $root): bool|string { $xml_o = new SimpleXMLElement("<$root>"); $this->array_to_xml($array, $xml_o); return $xml_o->asXML(); @@ -305,11 +282,8 @@ private function to_xml($array, $root) { /** * Transforms array to XML - * - * @param array $array - * @param string $xml_o */ - private function array_to_xml($array, &$xml_o) { + private function array_to_xml(array $array, SimpleXMLElement &$xml_o): void { foreach ($array as $key => $value) { if (is_array($value)) { if (!is_numeric($key)) { @@ -319,7 +293,6 @@ private function array_to_xml($array, &$xml_o) { $this->array_to_xml($value, $xml_o); } } else { - // htmspecialchars() because SimpleXMLElement doesn't escape ampersands $xml_o->addChild("$key", htmlspecialchars("$value")); } } @@ -330,11 +303,13 @@ private function array_to_xml($array, &$xml_o) { * * @return string JSON */ - public function to_json() { + public function to_json(): string { return json_encode($this->api_dataset); } - private function svninfo_from_build_data($prop, $data) { + static function svninfo_from_build_data($prop, $data): ?array { + $info = []; + if ($end_of_proj_name = strpos($prop, '.svn.info')) { # $prop matches '.svn.info'. $data, e.g. is: # Path: ApiCommonModel @@ -353,12 +328,14 @@ private function svninfo_from_build_data($prop, $data) { # Split that on newlines... $infoset = explode("\n", $data); foreach ($infoset as $attr) { - if (strlen($attr) == 0) { continue; } + if (strlen($attr) == 0) { + continue; + } # $attr is of the form # Path: ApiCommonModel # and # URL: https://cbilsvn.pmacs.upenn.edu/svn/apidb/ApiCommonModel/trunk - # etc. + # etc. # Split each of those by ':' (with a array lenght limit of '2' # so we don't split on the colons in the url or timestamps). $pairs = explode(':', $attr, 2); @@ -366,7 +343,7 @@ private function svninfo_from_build_data($prop, $data) { if (count($pairs) == 2) { $info[$pairs[0]] = trim($pairs[1]); } else { - return NULL; + return null; } } # Extract the working directory name from the $prop . e.g. @@ -377,8 +354,7 @@ private function svninfo_from_build_data($prop, $data) { $info['Working Directory'] = str_replace('.', '/', substr($prop, 0, $end_of_proj_name)); return $info; } - } + return null; + } } - -?> diff --git a/Site/dashboard/lib/UserAgent.php b/Site/dashboard/lib/UserAgent.php index 28b06f588..5ee04a3f6 100644 --- a/Site/dashboard/lib/UserAgent.php +++ b/Site/dashboard/lib/UserAgent.php @@ -1,56 +1,51 @@ ua = curl_init(); - if (is_array($opts)) { - $this->set_url($opts['url']); - if (array_key_exists('post_fields', $opts) && isset($opts['post_fields'])) { - $this->set_post_fields($opts['post_fields']); - } + * Options: + * * url + * * post_fields + **/ + function __construct(mixed $opts = null) { + $this->ua = curl_init(); + if (is_array($opts)) { + $this->set_url($opts['url']); + if (array_key_exists('post_fields', $opts) && isset($opts['post_fields'])) { + $this->set_post_fields($opts['post_fields']); } + } } - function get_content() { - $this->set_return_transfer(true); - return curl_exec($this->ua); + function get_content(): bool|string { + $this->set_return_transfer(true); + return curl_exec($this->ua); } - function set_url($url) { - $this->url = $url; - curl_setopt($this->ua, CURLOPT_URL, $url); - + function set_url(string $url): void { + $this->url = $url; + curl_setopt($this->ua, CURLOPT_URL, $url); } - function set_post_fields($post_fields) { - $this->set_use_post(true); - curl_setopt($this->ua, CURLOPT_POSTFIELDS, $post_fields); + function set_post_fields(string|array $post_fields): void { + $this->set_use_post(true); + curl_setopt($this->ua, CURLOPT_POSTFIELDS, $post_fields); } - function set_use_post($bool) { - curl_setopt($this->ua, CURLOPT_POST, $bool); + function set_use_post(bool $bool): void { + curl_setopt($this->ua, CURLOPT_POST, $bool); } - function set_return_transfer($bool) { - curl_setopt($this->ua, CURLOPT_RETURNTRANSFER, $bool); + function set_return_transfer(bool $bool): void { + curl_setopt($this->ua, CURLOPT_RETURNTRANSFER, $bool); } - function close() { - curl_close($this->ua); + function close(): void { + curl_close($this->ua); } } - -?> diff --git a/Site/dashboard/functions.php.inc b/Site/dashboard/lib/functions.php similarity index 60% rename from Site/dashboard/functions.php.inc rename to Site/dashboard/lib/functions.php index 67f11e50d..fd9e5f22d 100644 --- a/Site/dashboard/functions.php.inc +++ b/Site/dashboard/lib/functions.php @@ -1,34 +1,30 @@ -]*>([^<]+)<\/th>/', "\\1", $s); $s = preg_replace('/]*>([^<]+)<\/td>/', "\\1", $s); $vTmp = preg_split('/(

    [^<]+<\/h2>)/', $s, -1, PREG_SPLIT_DELIM_CAPTURE); - $vModules = array(); + $vModules = []; for ($i = 1; $i < count($vTmp); $i++) { if (preg_match('/

    ([^<]+)<\/h2>/', $vTmp[$i], $vMat)) { $vName = trim($vMat[1]); $vTmp2 = explode("\n", $vTmp[$i + 1]); - foreach ($vTmp2 AS $vOne) { + foreach ($vTmp2 as $vOne) { $vPat = '([^<]+)<\/info>'; $vPat3 = "/$vPat\s*$vPat\s*$vPat/"; $vPat2 = "/$vPat\s*$vPat/"; if (preg_match($vPat3, $vOne, $vMat)) { - $vModules[$vName][trim($vMat[1])] = array(trim($vMat[2]), trim($vMat[3])); + $vModules[$vName][trim($vMat[1])] = [trim($vMat[2]), trim($vMat[3])]; } elseif (preg_match($vPat2, $vOne, $vMat)) { $vModules[$vName][trim($vMat[1])] = trim($vMat[2]); } @@ -59,18 +55,20 @@ function parsePHPModules() { } // hattip to http://blog.rafaelsanches.com/2009/08/05/reading-java-style-properties-file-in-php/ -function parse_properties($property_file) { +function parse_properties($property_file): array { $property_text = file_get_contents($property_file); if (!$property_text) { - trigger_error("unable to read $property_file"); - return; + trigger_error("unable to read $property_file"); + return []; } - $result = array(); - $lines = split("\n", $property_text); + $result = []; + $lines = preg_split("\n", $property_text); $key = ""; $isWaitingOtherLine = false; + $value = ""; + foreach ($lines as $i => $line) { - if (empty($line) || (!$isWaitingOtherLine && strpos($line, "#") === 0)) + if (empty($line) || (!$isWaitingOtherLine && str_starts_with($line, "#"))) continue; if (!$isWaitingOtherLine) { $key = unescape_property(substr($line, 0, strpos($line, '='))); @@ -94,53 +92,55 @@ function parse_properties($property_file) { return $result; } -function unescape_property($value) { - $value = str_replace("\\#", "#", $value); - $value = str_replace("\\!", "!", $value); - $value = str_replace("\\=", "=", $value); - $value = str_replace("\\:", ":", $value); - $value = str_replace("\\t", "\t", $value); - $value = str_replace("\\n", "\n", $value); - $value = str_replace("\\r", "\r", $value); - return $value; +function unescape_property(array|string $value): array|string { + return str_replace(["\\#", "\\!", "\\=", "\\:", "\\t", "\\n", "\\r"], ["#", "!", "=", ":", "\t", "\n", "\r"], $value); } /** - Return date string for (current time - given milliseconds) - e.g. Wed 07 Dec 2011 11:44 AM + * Return date string for (current time - given milliseconds) + * e.g. Wed 07 Dec 2011 11:44 AM * */ -function date_on_elapsed_seconds($seconds) { +function date_on_elapsed_seconds($seconds): string { $now = time(); return date("D d M Y g:i A", $now - $seconds); } /** - return seconds elapsed as string, showing only the greatest non-zero period - and the next smaller period. - e.g. 3 days 4 minutes - or 4 minutes 3 seconds + * return seconds elapsed as string, showing only the greatest non-zero period + * and the next smaller period. + * e.g. 3 days 4 minutes + * or 4 minutes 3 seconds * */ -function seconds_as_periods($seconds) { +function seconds_as_periods($seconds): string { - $times = array(); - $gp = 0; // have found greatest non-zero time period + $times = []; + $gp = 0; // greatest non-zero time period found $days = floor($seconds / 60 / 60 / 24); - ($days != 0) && array_push($times, $days . 'd') && $gp = 1; + if ($days != 0) { + $times[] = $days . 'd'; + $gp = 1; + } $hours = ($seconds / 60 / 60) % 24; - ($hours != 0 || $gp == 1) && array_push($times, $hours . 'h') && $gp = 1; + if ($hours != 0 || $gp == 1) { + $times[] = $hours . 'h'; + $gp = 1; + } $minutes = ($seconds / 60) % 60; - ($minutes != 0 || $gp == 1) && array_push($times, $minutes . 'm') && $gp = 1; + if ($minutes != 0 || $gp == 1) { + $times[] = $minutes . 'm'; + $gp = 1; + } $seconds = ($seconds) % 60; - ($seconds != 0 || $gp == 1) && array_push($times, $seconds . 's') && $gp = 1; + if ($seconds != 0 || $gp == 1) { + $times[] = $seconds . 's'; + } $string = isset($times[0]) ? "$times[0]" : '0s'; $string .= isset($times[1]) ? " $times[1]" : ''; return $string; } - -?> diff --git a/Site/dashboard/lib/modules/ApacheInfo.php b/Site/dashboard/lib/modules/ApacheInfo.php index 45a5b3d56..ffecda754 100644 --- a/Site/dashboard/lib/modules/ApacheInfo.php +++ b/Site/dashboard/lib/modules/ApacheInfo.php @@ -1,32 +1,22 @@ -data_map = parsePHPModules(); } /** - Static initializer so one can chain methods at construction time - $c = ApacheInfo::init()->get_data_map(); - * */ - static public function init($opts = null) { - return new self($opts); - } - - /** - Return value for given key - * */ + * Return value for given key + */ function get($key) { if (array_key_exists($key, $this->data_map)) { return $this->data_map[$key]; @@ -34,20 +24,17 @@ function get($key) { return null; } - function get_data_map() { + function get_data_map(): array { return $this->data_map; } - function to_xml() { + function to_xml(): bool|string { $xml = new SimpleXMLElement(''); - array_walk_recursive($this->data_map, array($xml, 'addChild')); + array_walk_recursive($this->data_map, [$xml, 'addChild']); return $xml->asXML(); } - function to_json() { - return ison_encode($this->data_map); + function to_json(): bool|string { + return json_encode($this->data_map); } - } - -?> diff --git a/Site/dashboard/lib/modules/BuildInfo.php b/Site/dashboard/lib/modules/BuildInfo.php index 933c40482..dbbc5d72f 100644 --- a/Site/dashboard/lib/modules/BuildInfo.php +++ b/Site/dashboard/lib/modules/BuildInfo.php @@ -1,21 +1,22 @@ - - * @package Module - * @subpackage Project */ class BuildInfo { - function __construct() { + private array $data_map; + function __construct() { try { $this->data_map = parse_properties($_SERVER['GUS_HOME'] . '/.buildlog/gus-build-state.log'); } catch (Exception $e) { @@ -25,19 +26,16 @@ function __construct() { } /** - Return value for given key - * */ + * Return value for given key + */ function get($key) { if (array_key_exists($key, $this->data_map)) { - return $this->data_map{$key}; + return $this->data_map[$key]; } return null; } - function get_data_map() { + function get_data_map(): array { return $this->data_map; } - } - -?> diff --git a/Site/dashboard/lib/modules/CommentConfig.php b/Site/dashboard/lib/modules/CommentConfig.php index 948ba61e9..00931aca7 100644 --- a/Site/dashboard/lib/modules/CommentConfig.php +++ b/Site/dashboard/lib/modules/CommentConfig.php @@ -1,31 +1,38 @@ - - * @package Module - * @subpackage WdkConfiguration */ class CommentConfig extends JolModule { - /** * @return array CommentConfig attributes + * @throws Exception */ - public function attributes() { + public function attributes(): array { $req = new JolRequest($this->jol_base_url); - $read = new JolReadOperation(array( - 'mbean' => 'org.apidb.wdk:type=CommentConfig,path=' . $this->path_name, - )); + $read = new JolReadOperation(['mbean' => $this->get_mbean()]); $req->add_operation($read); $response = $req->invoke(); if ($response->has_error()) { - return array(); + return []; } + + /** + * If response->has_error returns false, then we know that the type of the + * response array values is JolQueryResultItemSuccess. + * + * @noinspection PhpPossiblePolymorphicInvocationInspection + */ return $response[0]->value(); } + protected function get_mbean(): string { + return 'org.apidb.wdk:type=CommentConfig,path=' . $this->path_name; + } } - -?> diff --git a/Site/dashboard/lib/modules/ConnectionPool.php b/Site/dashboard/lib/modules/ConnectionPool.php index 0260296fc..8caab6951 100644 --- a/Site/dashboard/lib/modules/ConnectionPool.php +++ b/Site/dashboard/lib/modules/ConnectionPool.php @@ -1,47 +1,20 @@ - - * @package Module - * @subpackage Database - */ class ConnectionPool extends JolModule { - protected $role; + protected string $role; - public function __construct($dbName) { + public function __construct(string $dbName) { parent::__construct(); $this->role = $dbName; } - /** - * @return array Database attributes - */ - public function attributes() { - $req = new JolRequest($this->jol_base_url); - $read = new JolReadOperation(array( - 'mbean' => $this->get_mbean(), - )); - $req->add_operation($read); - $response = $req->invoke(); - if ($response->has_error()) { - $error1 = $response->get_errors(); - throw new Exception($error1[0]->error() . " for " . $req->curl_cli_equivalent()); - } - return $response[0]->value(); - } - - private function get_mbean() { + protected function get_mbean(): string { return 'org.gusdb.wdk:type=Database,role=' . - $this->role . ',data=ConnectionPool' . - ',path=' . $this->path_name; + $this->role . ',data=ConnectionPool' . + ',path=' . $this->path_name; } - } - -?> diff --git a/Site/dashboard/lib/modules/DBInstances.php b/Site/dashboard/lib/modules/DBInstances.php index 27a681cf2..53608cb90 100644 --- a/Site/dashboard/lib/modules/DBInstances.php +++ b/Site/dashboard/lib/modules/DBInstances.php @@ -1,43 +1,15 @@ - - * @package Module - * @subpackage Database - */ class DBInstances extends JolModule { - - public function __construct() { - parent::__construct(); - } - - /** - * @return array Database attributes - */ - public function attributes() { - $req = new JolRequest($this->jol_base_url); - $read = new JolReadOperation(array( - 'mbean' => $this->get_mbean(), - )); - $req->add_operation($read); - $response = $req->invoke(); - if ($response->has_error()) { - $error1 = $response->get_errors(); - throw new Exception($error1[0]->error() . " for " . $req->curl_cli_equivalent()); - } - return $response[0]->value(); - } - - private function get_mbean() { + protected function get_mbean(): string { return 'org.gusdb.wdk:type=Database,status=DBInstances' . - ',path=' . $this->path_name; + ',path=' . $this->path_name; } - } - -?> diff --git a/Site/dashboard/lib/modules/Database.php b/Site/dashboard/lib/modules/Database.php index 61c48b4f0..ac3505af7 100644 --- a/Site/dashboard/lib/modules/Database.php +++ b/Site/dashboard/lib/modules/Database.php @@ -1,65 +1,43 @@ - - * @package Module - * @subpackage Database - */ class Database extends JolModule { - protected $role; + protected string $role; /** see org.gusdb.wdk.model.WdkModel for - allowed $dbName values **/ - public function __construct($dbName) { + * allowed $dbName values **/ + public function __construct(string $dbName) { parent::__construct(); $this->role = $dbName; } /** - * @return array Database attributes - */ - public function attributes() { - $req = new JolRequest($this->jol_base_url); - $read = new JolReadOperation(array( - 'mbean' => $this->get_mbean(), - )); - $req->add_operation($read); - $response = $req->invoke(); - if ($response->has_error()) { - $error1 = $response->get_errors(); - throw new Exception($error1[0]->error() . " for " . $req->curl_cli_equivalent()); - } - return $response[0]->value(); - } - - /** - * * @return boolean TRUE if operation was successful, otherwise FALSE + * @throws Exception */ - public function refresh() { + public function refresh(): bool { $req = new JolRequest($this->jol_base_url); - $exec = new JolExecOperation(array( - 'mbean' => $this->get_mbean(), - 'operation' => 'reload', - )); + $exec = new JolExecOperation([ + 'mbean' => $this->get_mbean(), + 'operation' => 'reload', + ]); $req->add_operation($exec); $response = $req->invoke(); return $response[0]->is_success(); } - private function get_mbean() { + protected function get_mbean(): string { return 'org.gusdb.wdk:type=Database,' . - 'role=' . $this->role . - ',data=Environment' . - ',path=' . $this->path_name; + 'role=' . $this->role . + ',data=Environment' . + ',path=' . $this->path_name; } - } - -?> diff --git a/Site/dashboard/lib/modules/JolModule.php b/Site/dashboard/lib/modules/JolModule.php index 35530e0cb..8cba835f3 100644 --- a/Site/dashboard/lib/modules/JolModule.php +++ b/Site/dashboard/lib/modules/JolModule.php @@ -1,10 +1,7 @@ -context_path = $c->get('context_path'); $this->wdk_mbean_domain = $c->get('wdk_mbean_domain'); $this->engine_host = $c->get('tomcat_engine_host_name'); - $this->path_name = '//' . $this->engine_host . $this->context_path; + $this->path_name = '//' . $this->engine_host . $this->context_path; } -} + protected abstract function get_mbean(): string; + + /** + * @throws Exception + */ + function attributes(): array { + $req = new JolRequest($this->jol_base_url); + $read = new JolReadOperation(['mbean' => $this->get_mbean()]); + $req->add_operation($read); + $response = $req->invoke(); + if ($response->has_error()) { + $error1 = $response->get_errors(); + throw new Exception($error1[0]->error() . " for " . $req->curl_cli_equivalent()); + } -?> + /** + * If response->has_error returns false, then we know that the type of the + * response array values is JolQueryResultItemSuccess. + * + * @noinspection PhpPossiblePolymorphicInvocationInspection + */ + return $response[0]->value(); + } +} diff --git a/Site/dashboard/lib/modules/Jvm.php b/Site/dashboard/lib/modules/Jvm.php index ffcc016bf..44685421b 100644 --- a/Site/dashboard/lib/modules/Jvm.php +++ b/Site/dashboard/lib/modules/Jvm.php @@ -1,18 +1,22 @@ - - * @package Module - * @subpackage Tomcat */ class Jvm extends JolModule { - private $uptime_as_text; + private string $uptime_as_text; public function __construct() { parent::__construct(); @@ -20,31 +24,35 @@ public function __construct() { /** * @return array JVM attributes + * @throws Exception */ - public function attributes() { + public function attributes(): array { $req = new JolRequest($this->jol_base_url); - $read = new JolReadOperation(array( - 'mbean' => 'java.lang:type=Runtime', - 'attribute' => array('Uptime') - )); + $read = new JolReadOperation([ + 'mbean' => $this->get_mbean(), + 'attribute' => ['Uptime'] + ]); $req->add_operation($read); $response = $req->invoke(); + // FIXME: This call could cause problems if the response was an error. The + // error result type does not have a value() method. $attrs = $response[0]->value(); - $this->set_uptime_as_text($attrs{'Uptime'}); + $this->set_uptime_as_text($attrs['Uptime']); return $attrs; } - public function uptime_as_text() { + public function uptime_as_text(): string { return $this->uptime_as_text; } - private function set_uptime_as_text($uptime) { + protected function get_mbean(): string { + return 'java.lang:type=Runtime'; + } + + private function set_uptime_as_text($uptime): void { $seconds_up = $uptime / 1000; $string = seconds_as_periods($seconds_up); $string .= ' (since ' . date_on_elapsed_seconds($seconds_up) . ')'; $this->uptime_as_text = $string; } - } - -?> diff --git a/Site/dashboard/lib/modules/Logger.php b/Site/dashboard/lib/modules/Logger.php index 545c292b0..9030f2dc9 100644 --- a/Site/dashboard/lib/modules/Logger.php +++ b/Site/dashboard/lib/modules/Logger.php @@ -1,56 +1,70 @@ - - * @package Module - * @subpackage Tomcat */ class Logger extends JolModule { /** * @return array of attributes + * @throws Exception */ - public function attributes() { + public function attributes(): array { $req = new JolRequest($this->jol_base_url); - $read = new JolReadOperation(array( - 'mbean' => 'org.gusdb.wdk:type=Log4J,path=' . $this->path_name, - )); + $read = new JolReadOperation([ + 'mbean' => $this->get_mbean(), + ]); $req->add_operation($read); $response = $req->invoke(); if ($response->has_error()) { trigger_error('Error. Response was ' . - substr($response->get_json_result(), 0, 200) . - "...\nFor request " . $req->http_postdata_as_json()); - return null; + substr($response->get_json_result(), 0, 200) . + "...\nFor request " . $req->http_postdata_as_json()); + return []; } + /** + * If response->has_error returns false, then we know that the type of the + * response array values is JolQueryResultItemSuccess. + * + * @noinspection PhpPossiblePolymorphicInvocationInspection + */ return $response[0]->value(); } - public function update($logger_map) { + /** + * @throws Exception + */ + public function update($logger_map): bool { $req = new JolRequest($this->jol_base_url); - $mbean = 'org.gusdb.wdk:type=Log4J,path=' . $this->path_name; + $mbean = $this->get_mbean(); foreach ($logger_map as $name => $value) { $op = new JolWriteOperation(array( - 'mbean' => $mbean, - 'attribute' => $name, - 'value' => $value, - )); + 'mbean' => $mbean, + 'attribute' => $name, + 'value' => $value, + )); $req->add_operation($op); } + $response = $req->invoke(); + if ($response->has_error()) { trigger_error('Error. Response was ' . - substr($response->get_json_result(), 0, 200) . - "...\nFor request " . $req->http_postdata_as_json()); + substr($response->get_json_result(), 0, 200) . + "...\nFor request " . $req->http_postdata_as_json()); } + return $response->is_success(); } + protected function get_mbean(): string { + return 'org.gusdb.wdk:type=Log4J,path=' . $this->path_name; + } } -?> diff --git a/Site/dashboard/lib/modules/ModelConfig.php b/Site/dashboard/lib/modules/ModelConfig.php index a00e77a81..81baf478c 100644 --- a/Site/dashboard/lib/modules/ModelConfig.php +++ b/Site/dashboard/lib/modules/ModelConfig.php @@ -1,14 +1,13 @@ - - * @package Module - * @subpackage WDK */ class ModelConfig extends JolModule { @@ -18,56 +17,62 @@ public function __construct() { /** * @return array ModelConfig attributes + * @throws Exception */ - public function attributes() { + public function attributes(): array { $req = new JolRequest($this->jol_base_url); - $read = new JolReadOperation(array( - 'mbean' => $this->wdk_mbean_domain . ':type=ModelConfig,path=' . $this->path_name, - )); + $read = new JolReadOperation(['mbean' => $this->get_mbean()]); $req->add_operation($read); $response = $req->invoke(); + // FIXME: This call could cause problems if the response was an error. The + // error result type does not have a value() method. return $this->re_section_data($response[0]->value()); } + protected function get_mbean(): string { + return $this->wdk_mbean_domain . ':type=ModelConfig,path=' . $this->path_name; + } + /** - * JMX data for model-config is flat with section names encoded as a prefix. + * JMX data for model-config is flat with section names encoded as a prefix. * - * In situ configuration looks like - * [ + * This function reshapes this back into a sectional hierarchy + * global => [ * smtpServer => localhost, * email => a@b.com - * ] + * ] + * + * @param array $raw_data * * @return array */ - private function re_section_data($raw_data) { - $data_tree = array(); + private function re_section_data(array $raw_data): array { + $data_tree = []; + foreach ($raw_data as $k => $v) { # regex delimiter: starts with [, capture all characters not a ], followed by ] and a space - $node = preg_split("/^\[([^\]]+)\] /", $k, null, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); + $node = preg_split("/^\[([^]]+)] /", $k, null, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); if (count($node) > 1) { $section = $node[0]; - (array_key_exists($section, $data_tree)) || $data_tree[$section] = array(); + (array_key_exists($section, $data_tree)) || $data_tree[$section] = []; $data_tree[$section][$node[1]] = $v; } else { - array_push($data_tree, array($node[0] => $v)); + $data_tree[] = [$node[0] => $v]; } } + return $data_tree; } - } - -?> diff --git a/Site/dashboard/lib/modules/OpenConnections.php b/Site/dashboard/lib/modules/OpenConnections.php index 2e0cc9cd7..4a90859c2 100644 --- a/Site/dashboard/lib/modules/OpenConnections.php +++ b/Site/dashboard/lib/modules/OpenConnections.php @@ -1,61 +1,32 @@ - - * @package Module - * @subpackage Database - */ class OpenConnections extends JolModule { - - private $mbean; - protected $role; - - public function __construct() { - parent::__construct(); - } - - /** - * @return array Database attributes - */ - public function attributes() { - $req = new JolRequest($this->jol_base_url); - $read = new JolReadOperation(array( - 'mbean' => $this->get_mbean(), - )); - $req->add_operation($read); - $response = $req->invoke(); - if ($response->has_error()) { - $error1 = $response->get_errors(); - throw new Exception($error1[0]->error() . " for " . $req->curl_cli_equivalent()); - } - return $response[0]->value(); - } - - private function get_mbean() { + protected function get_mbean(): string { return 'org.gusdb.wdk:type=Database,status=OpenConnections' . - ',path=' . $this->path_name; + ',path=' . $this->path_name; } /** - * * @return boolean TRUE if operation was successful, otherwise FALSE + * @throws Exception */ - public function dumpDbConnectionStatsToLog($dbclass) { + public function dumpDbConnectionStatsToLog(string $dbclass): bool { $req = new JolRequest($this->jol_base_url); - $exec = new JolExecOperation(array( - 'mbean' => $this->get_mbean(), - 'operation' => "dumpOpen${dbclass}Connections", - )); + $exec = new JolExecOperation([ + 'mbean' => $this->get_mbean(), + 'operation' => "dumpOpen${dbclass}Connections", + ]); $req->add_operation($exec); $response = $req->invoke(); return $response[0]->is_success(); } - } - -?> diff --git a/Site/dashboard/lib/modules/ProxyInfo.php b/Site/dashboard/lib/modules/ProxyInfo.php index 0233424b0..7f64652de 100644 --- a/Site/dashboard/lib/modules/ProxyInfo.php +++ b/Site/dashboard/lib/modules/ProxyInfo.php @@ -1,60 +1,56 @@ - + */ + var array $data_map; function __construct() { - $this->data_map = array( - 'via' => NULL, - 'proxy_app' => NULL, - 'proxy_host' => NULL, - 'proxied_host' => NULL, - 'upstream_server' => NULL, - 'nginx_proxy_switcher' => NULL, - ); - $this->init(); + $this->data_map = $this->init(); } - function init() { + private function init(): array { $c = new Configuration(); $headers = apache_request_headers(); if (!isset($headers['Via'])) { // this is not a proxied site - return $this->data_map; + return [ + 'via' => null, + 'proxy_app' => null, + 'proxy_host' => null, + 'proxied_host' => null, + 'upstream_server' => null, + 'nginx_proxy_switcher' => null, + ]; } // if apache proxies to a relative URL, the request goes back through // the proxy resulting in appended header, e.g. // nginx at 128.192.75.110, nginx at 128.192.75.110 // So, split and take the first. - list($via) = explode(',', $headers['Via']); - - list($proxy_app, $prox_host) = explode(' at ', $via); - - $this->data_map = array( - 'via' => $headers['Via'], - 'proxy_app' => $proxy_app, - 'proxy_host' => $prox_host, - 'proxied_host' => $headers['Host'], - 'upstream_server' => upstreamServer(), - 'nginx_proxy_switcher' => $c->get('nginx_proxy_switcher'), - ); + [$via] = explode(',', $headers['Via']); + + [$proxy_app, $prox_host] = explode(' at ', $via); + + return [ + 'via' => $headers['Via'], + 'proxy_app' => $proxy_app, + 'proxy_host' => $prox_host, + 'proxied_host' => $headers['Host'], + 'upstream_server' => upstreamServer(), + 'nginx_proxy_switcher' => $c->get('nginx_proxy_switcher'), + ]; } - function attributes() { + function attributes(): array { return $this->data_map; } - } - -?> \ No newline at end of file diff --git a/Site/dashboard/lib/modules/ServletInfo.php b/Site/dashboard/lib/modules/ServletInfo.php index a95c916d7..cc1f55df1 100644 --- a/Site/dashboard/lib/modules/ServletInfo.php +++ b/Site/dashboard/lib/modules/ServletInfo.php @@ -1,53 +1,64 @@ - - * @package Module - * @subpackage Tomcat -*/ + */ class ServletInfo extends JolModule { - private $major_version; + private string $major_version; /** * @return array servlet attributes + * @throws Exception */ - public function attributes() { - //$domain = $this->configuration->get('tomcat_engine_name'); + public function attributes(): array { $req = new JolRequest($this->jol_base_url); - $read = new JolReadOperation(array( - 'mbean' => 'org.apidb.wdk:type=ServletVersions' . ',path=' . $this->path_name, - )); + $read = new JolReadOperation(['mbean' => $this->get_mbean()]); $req->add_operation($read); $response = $req->invoke(); + if ($response->has_error()) { - trigger_error('Error. Response was ' . - substr($response->get_json_result(), 0, 200) . - "...\nFor request " . $req->http_postdata_as_json()); - return null; + trigger_error( + 'Error. Response was ' . + substr($response->get_json_result(), 0, 200) . + "...\nFor request " . $req->http_postdata_as_json() + ); + return []; } + + /** + * If response->has_error returns false, then we know that the type of the + * response array values is JolQueryResultItemSuccess. + * + * @noinspection PhpPossiblePolymorphicInvocationInspection + */ $attrs = $response[0]->value(); - $this->set_major_version($attrs{'ServerInfo'}); - $attrs{'MajorVersion'} = $this->set_major_version($attrs{'ServerInfo'}); + + $this->set_major_version($attrs['ServerInfo']); + $attrs['MajorVersion'] = $this->major_version(); + return $attrs; } + public function major_version(): string { + return $this->major_version; + } + + protected function get_mbean(): string { + return 'org.apidb.wdk:type=ServletVersions' . ',path=' . $this->path_name; + } + /** * Set Tomcat major version given Tomcat serverinfo string. * "Apache Tomcat/6.0.43" returns "6" */ - private function set_major_version($serverinfo) { + private function set_major_version(string $serverinfo): void { preg_match(';.+/(\d)\..+;', $serverinfo, $m); $this->major_version = $m[1]; } - - public function major_version() { - return $this->major_version; - } - } - -?> diff --git a/Site/dashboard/lib/modules/StageValues.php b/Site/dashboard/lib/modules/StageValues.php index 2385cf3ac..d16f4b916 100644 --- a/Site/dashboard/lib/modules/StageValues.php +++ b/Site/dashboard/lib/modules/StageValues.php @@ -1,17 +1,21 @@ - - * @package Module - * @subpackage Project */ class StageValues { - function __construct() { + /** + * @var array|mixed + */ + private array $data_map; + function __construct() { try { $this->data_map = parse_properties('/etc/sysconfig/httpd'); // clean up key names, remove non-RELEASE keys @@ -20,8 +24,8 @@ function __construct() { $newkey = ltrim(preg_replace('/(?:export\s+)?WEBSITE_RELEASE_STAGE_/', '', $key)); $this->data_map[$newkey] = $this->data_map[$key]; } - unset($this->data_map[$key]); - } + unset($this->data_map[$key]); + } } catch (Exception $e) { echo 'Exception: ', $e->getMessage(), "\n"; @@ -30,30 +34,26 @@ function __construct() { } /** - Return value for given key + * Return value for given key * */ - function get($key) { + function get(string $key) { if (array_key_exists($key, $this->data_map)) { - return $this->data_map{$key}; + return $this->data_map[$key]; } return null; } - - - /** - * Flip he key/values relative to what's in the httpd file. - * So, - * 'export WEBSITE_RELEASE_STAGE_INTEGRATE=20' - * becomes '20 => INTEGRATE' - */ - function get_flipped_data_map() { - return array_flip($this->data_map); - } - - function get_data_map() { + + function get_data_map(): array { return $this->data_map; } + /** + * Flip the key/values relative to what's in the httpd file. + * So, + * 'export WEBSITE_RELEASE_STAGE_INTEGRATE=20' + * becomes '20 => INTEGRATE' + */ + function get_flipped_data_map(): array { + return array_flip($this->data_map); + } } - -?> diff --git a/Site/dashboard/lib/modules/TuningManagerStatus.php b/Site/dashboard/lib/modules/TuningManagerStatus.php index 93e59a17f..daf6169e7 100644 --- a/Site/dashboard/lib/modules/TuningManagerStatus.php +++ b/Site/dashboard/lib/modules/TuningManagerStatus.php @@ -1,38 +1,40 @@ - - * @package Module - * @subpackage Database - */ class TuningManagerStatus extends JolModule { - - public function __construct() { - parent::__construct(); - } - /** * @return array TuningManagerStatus attributes + * @throws Exception */ - public function attributes() { + public function attributes(): array { $req = new JolRequest($this->jol_base_url); - $read = new JolReadOperation(array( - 'mbean' => 'org.apidb.wdk:type=TuningManagerStatus,path=' . $this->path_name, - )); + $read = new JolReadOperation(['mbean' => $this->get_mbean()]); $req->add_operation($read); $response = $req->invoke(); if ($response->has_error()) { - return array(); - #$error1 = $response->get_errors(); - #throw new Exception($error1[0]->error() . " for " . $req->curl_cli_equivalent()); + return []; } + + /** + * If response->has_error returns false, then we know that the type of the + * response array values is JolQueryResultItemSuccess. + * + * @noinspection PhpPossiblePolymorphicInvocationInspection + */ return $response[0]->value(); } + protected function get_mbean(): string { + return 'org.apidb.wdk:type=TuningManagerStatus,path=' . $this->path_name; + } } -?> diff --git a/Site/dashboard/lib/modules/WdkCache.php b/Site/dashboard/lib/modules/WdkCache.php index bed26a396..0f5a50bb9 100644 --- a/Site/dashboard/lib/modules/WdkCache.php +++ b/Site/dashboard/lib/modules/WdkCache.php @@ -1,59 +1,59 @@ - - * @package Module - * @subpackage WDK */ class WdkCache extends JolModule { - - public function __construct() { - parent::__construct(); - } - /** * @return array Application Database attributes + * @throws Exception */ - public function attributes() { + public function attributes(): array { $req = new JolRequest($this->jol_base_url); - $read = new JolReadOperation(array( - 'mbean' => $this->wdk_mbean_domain . ':type=Cache,path=' . $this->path_name, - )); + $read = new JolReadOperation(['mbean' => $this->get_mbean()]); $req->add_operation($read); $response = $req->invoke(); + // FIXME: This call could cause problems if the response was an error. The + // error result type does not have a value() method. return $response[0]->value(); } /** - * * @return boolean TRUE if operation was successful, otherwise FALSE + * @throws Exception */ - public function reset() { + public function reset(): bool { $req = new JolRequest($this->jol_base_url); - $exec = new JolExecOperation(array( - 'mbean' => $this->wdk_mbean_domain . ':type=Cache,path=' . $this->path_name, - 'operation' => 'resetWdkCache', - )); + $exec = new JolExecOperation([ + 'mbean' => $this->get_mbean(), + 'operation' => 'resetWdkCache', + ]); $req->add_operation($exec); $response = $req->invoke(); return $response[0]->is_success(); } + /** + * @throws Exception + */ public function toggleWdkIsCaching() { $req = new JolRequest($this->jol_base_url); - $exec = new JolExecOperation(array( - 'mbean' => $this->wdk_mbean_domain . ':type=Cache,path=' . $this->path_name, - 'operation' => 'toggleWdkIsCaching', - )); + $exec = new JolExecOperation([ + 'mbean' => $this->get_mbean(), + 'operation' => 'toggleWdkIsCaching', + ]); $req->add_operation($exec); $response = $req->invoke(); - return $response[0]->is_success(); + return $response[0]->is_success(); } -} -?> + protected function get_mbean(): string { + return $this->wdk_mbean_domain . ':type=Cache,path=' . $this->path_name; + } +} diff --git a/Site/dashboard/lib/modules/WdkMeta.php b/Site/dashboard/lib/modules/WdkMeta.php index 661033316..84d372e95 100644 --- a/Site/dashboard/lib/modules/WdkMeta.php +++ b/Site/dashboard/lib/modules/WdkMeta.php @@ -1,37 +1,44 @@ - - * @package Module - * @subpackage WDK */ class WdkMeta extends JolModule { /** * @return array of attributes + * @throws Exception */ - public function attributes() { + public function attributes(): array { $req = new JolRequest($this->jol_base_url); - $read = new JolReadOperation(array( - 'mbean' => $this->wdk_mbean_domain . ':type=Meta,path=' . $this->path_name, - )); + $read = new JolReadOperation(['mbean' => $this->get_mbean()]); $req->add_operation($read); $response = $req->invoke(); if ($response->has_error()) { - trigger_error('Error. Response was ' . - substr($response->get_json_result(), 0, 200) . - "...\nFor request " . $req->http_postdata_as_json()); - return null; + trigger_error( + 'Error. Response was ' . + substr($response->get_json_result(), 0, 200) . + "...\nFor request " . $req->http_postdata_as_json() + ); + return []; } + /** + * If response->has_error returns false, then we know that the type of the + * response array values is JolQueryResultItemSuccess. + * + * @noinspection PhpPossiblePolymorphicInvocationInspection + */ return $response[0]->value(); } + protected function get_mbean(): string { + return $this->wdk_mbean_domain . ':type=Meta,path=' . $this->path_name; + } } - -?> diff --git a/Site/dashboard/lib/modules/WdkProperties.php b/Site/dashboard/lib/modules/WdkProperties.php index 757973da9..7076ea6ab 100644 --- a/Site/dashboard/lib/modules/WdkProperties.php +++ b/Site/dashboard/lib/modules/WdkProperties.php @@ -1,31 +1,31 @@ - - * @package Module - * @subpackage WDK - */ class WdkProperties extends JolModule { /** * @return array WDK properties + * @throws Exception */ - public function attributes() { + public function attributes(): array { $req = new JolRequest($this->jol_base_url); - $read = new JolReadOperation(array( - 'mbean' => $this->wdk_mbean_domain . ':type=Properties,path=' . $this->path_name, - )); + $read = new JolReadOperation(['mbean' => $this->get_mbean()]); $req->add_operation($read); $response = $req->invoke(); + // FIXME: This call could cause problems if the response was an error. The + // error result type does not have a value() method. return $response[0]->value(); } + protected function get_mbean(): string { + return $this->wdk_mbean_domain . ':type=Properties,path=' . $this->path_name; + } } - -?> diff --git a/Site/dashboard/lib/modules/Webapp.php b/Site/dashboard/lib/modules/Webapp.php index ccc5747ed..4e9eeaaff 100644 --- a/Site/dashboard/lib/modules/Webapp.php +++ b/Site/dashboard/lib/modules/Webapp.php @@ -1,22 +1,24 @@ - - * @package Module - * @subpackage Tomcat */ class Webapp extends JolModule { - private $uptime_as_text; - private $webapp_read_op; - private $domain; - private $attributes; + private string $uptime_as_text; + private string $domain; public function __construct() { parent::__construct(); @@ -26,91 +28,97 @@ public function __construct() { /** * @return array of attributes + * + * @throws Exception if Jolokia request fails. + * @noinspection PhpPossiblePolymorphicInvocationInspection */ - public function attributes() { - - $loaders = array( - // Tomcat 6.x - new JolReadOperation(array( - 'mbean' => $this->domain . - ':type=Loader,path=' . $this->context_path . - ',host=' . $this->engine_host, - 'attribute' => array('loaderRepositoriesString'), // use array so we get array response - )), - // Tomcat 8.x - new JolReadOperation(array( - 'mbean' => $this->domain . - ':type=Loader,context=' . $this->context_path . - ',host=' . $this->engine_host, - 'attribute' => array('loaderRepositoriesString'), // use array so we get array response - )), - ); - - $app = new JolReadOperation(array( - 'mbean' => "$this->domain:" . - 'j2eeType=WebModule,name=//' . - $this->engine_host . $this->context_path . - ',J2EEApplication=none,J2EEServer=none', - 'attribute' => array('startTime', 'path'), - )); + public function attributes(): array { + $loaders = [ + // Tomcat 6.x + new JolReadOperation([ + 'mbean' => $this->domain . + ':type=Loader,path=' . $this->context_path . + ',host=' . $this->engine_host, + 'attribute' => ['loaderRepositoriesString'], // use array so we get array response + ]), + // Tomcat 8.x + new JolReadOperation([ + 'mbean' => $this->domain . + ':type=Loader,context=' . $this->context_path . + ',host=' . $this->engine_host, + 'attribute' => ['loaderRepositoriesString'], // use array so we get array response + ]), + ]; + + $app = new JolReadOperation([ + 'mbean' => "$this->domain:" . + 'j2eeType=WebModule,name=//' . + $this->engine_host . $this->context_path . + ',J2EEApplication=none,J2EEServer=none', + 'attribute' => ['startTime', 'path'], + ]); // list of all the other webapp paths deployed in the instance - $all_deployed_webmodules = new JolReadOperation(array( - 'mbean' => "$this->domain:" . - 'j2eeType=WebModule,*' , - 'attribute' => array('path'), - )); - - $response = null; - foreach($loaders as $loader) { - $req = new JolRequest($this->jol_base_url); - $req->add_operation($loader); - $req->add_operation($app); - $req->add_operation($all_deployed_webmodules); - - $response = $req->invoke(); - if ( ! $response->has_error()) { - break; - } + $all_deployed_webmodules = new JolReadOperation([ + 'mbean' => "$this->domain:" . 'j2eeType=WebModule,*', + 'attribute' => ['path'], + ]); + + foreach ($loaders as $loader) { + $req = new JolRequest($this->jol_base_url); + $req->add_operation($loader); + $req->add_operation($app); + $req->add_operation($all_deployed_webmodules); + + $response = $req->invoke(); + if (!$response->has_error()) { + break; + } } if ($response->has_error()) { throw new Exception('invalid response: ' . $response->get_json_result()); } - $this->attributes = array_merge_recursive($response[0]->value(), $response[1]->value()); + $attributes = array_merge_recursive($response[0]->value(), $response[1]->value()); + + $attributes['loaderRepositoriesString'] = str_replace( + 'file:', + '', + $attributes['loaderRepositoriesString'] + ); - $this->attributes{'loaderRepositoriesString'} = str_replace( - 'file:', '', $this->attributes{'loaderRepositoriesString'}); - - $this->attributes{'other_deployed_webapps'} = array(); + $attributes['other_deployed_webapps'] = []; $all_webmodules = array_merge_recursive($response[2]->value()); foreach ($all_webmodules as $module) { - if ($this->attributes{'path'} == $module{'path'}) { continue; } - $webapp = preg_replace('/^\//', '', $module{'path'}); - array_push($this->attributes{'other_deployed_webapps'}, ($webapp ?: 'ROOT')); + if ($attributes['path'] == $module['path']) { + continue; + } + $webapp = preg_replace('/^\//', '', $module['path']); + $attributes['other_deployed_webapps'][] = ($webapp ?: 'ROOT'); } - $this->set_uptime_as_text($this->attributes{'startTime'}); - return $this->attributes; - } + $this->set_uptime_as_text($attributes['startTime']); + return $attributes; + } /** * Reloads the webapp and refreshes the attributes collection. * * @return boolean TRUE if operation was successful, otherwise FALSE + * + * @throws Exception if Jolokia request fails. */ - public function reload() { - + public function reload(): bool { $req = new JolRequest($this->jol_base_url); - $exec = new JolExecOperation(array( - 'mbean' => "$this->domain:" . - 'j2eeType=WebModule,name=//' . - $this->engine_host . $this->context_path . - ',J2EEApplication=none,J2EEServer=none', - 'operation' => 'reload', - )); + $exec = new JolExecOperation([ + 'mbean' => "$this->domain:" . + 'j2eeType=WebModule,name=//' . + $this->engine_host . $this->context_path . + ',J2EEApplication=none,J2EEServer=none', + 'operation' => 'reload', + ]); $req->add_operation($exec); $response = $req->invoke(); if ($response->has_error()) { @@ -123,19 +131,21 @@ public function reload() { return $response[0]->is_success(); } - public function uptime_as_text() { + public function uptime_as_text(): string { return $this->uptime_as_text; } - private function set_uptime_as_text($starttime) { + protected function get_mbean(): string { + return ''; + } + + private function set_uptime_as_text(int $starttime): void { if ($starttime == 0) { - return null; + return; } $seconds_elapsed = max(0, (time() - ($starttime / 1000))); $string = seconds_as_periods($seconds_elapsed); $string .= ' (since ' . date_on_elapsed_seconds($seconds_elapsed) . ')'; $this->uptime_as_text = $string; } - } -?> diff --git a/Site/dashboard/lib/modules/WorkflowStatus.php b/Site/dashboard/lib/modules/WorkflowStatus.php index 06da9f3f2..28f063783 100644 --- a/Site/dashboard/lib/modules/WorkflowStatus.php +++ b/Site/dashboard/lib/modules/WorkflowStatus.php @@ -1,34 +1,38 @@ -jol_base_url); - $read = new JolReadOperation(array( - 'mbean' => 'org.apidb.wdk:type=WorkflowStatus,path=' . $this->path_name, - )); + $read = new JolReadOperation(['mbean' => $this->get_mbean()]); $req->add_operation($read); $response = $req->invoke(); if ($response->has_error()) { - return array(); - #$error1 = $response->get_errors(); - #throw new Exception($error1[0]->error() . " for " . $req->curl_cli_equivalent()); + return []; } + + /** + * If response->has_error returns false, then we know that the type of the + * response array values is JolQueryResultItemSuccess. + * + * @noinspection PhpPossiblePolymorphicInvocationInspection + */ return $response[0]->value(); } + protected function get_mbean(): string { + return 'org.apidb.wdk:type=WorkflowStatus,path=' . $this->path_name; + } } -?> diff --git a/Site/dashboard/lib/xml/functions.php b/Site/dashboard/lib/xml/functions.php new file mode 100644 index 000000000..4bb3a3c3b --- /dev/null +++ b/Site/dashboard/lib/xml/functions.php @@ -0,0 +1,41 @@ +createElement('error', $error_str); +} + + +/** traverse node tree, print values **/ +function print_node_values(DOMNode $node): void { + if ($node->hasChildNodes()) { + foreach ($node->childNodes as $child) { + print_node_values($child); + } + } else { + echo trim($node->nodeValue) . "\n"; + } +} + + +/** + * merge + * + * + + * + * into + * + * + * + * + **/ +function merge_child_nodes_with_doc(DOMDocument $dom_doc, DOMDocument $source): void { + foreach ($source->documentElement->childNodes as $node) { + $importNode = $dom_doc->importNode($node, true); + $dom_doc->documentElement->appendChild($importNode); + } +} diff --git a/Site/dashboard/lib/xmlfunctions.inc b/Site/dashboard/lib/xmlfunctions.inc deleted file mode 100644 index af321b528..000000000 --- a/Site/dashboard/lib/xmlfunctions.inc +++ /dev/null @@ -1,63 +0,0 @@ -createElement('error'); - $value = $dom_doc->createTextNode($error_str); - $node->appendChild($value); - return $node; -} - - -/** traverse node tree, print values **/ -function print_node_values($node) { - if ( ! $node) return; - if ($node->hasChildNodes()) { - foreach($node->childNodes as $child) { - print_node_values($child); - } - } else { - print trim($node->nodeValue) . "\n"; - } -} - - -function import_node($dom_doc, $source) { - if ( ! $source || ! $source->documentElement ) { - $node = error_node($dom_doc, 'unavailable'); - } else { - $node = $source->documentElement; - } - $root = $dom_doc->documentElement; - $root->appendChild($dom_doc->importNode($node, true)); -} - - -/** -merge - - + - -into - - - - - -**/ -function merge_child_nodes_with_doc($dom_doc, $source) { - foreach ($source->documentElement->childNodes as $node) { - $importNode = $dom_doc->importNode($node,TRUE); - $dom_doc->documentElement->appendChild($importNode); - } -} -?> diff --git a/Site/dashboard/test/Memory.php b/Site/dashboard/test/Memory.php index b2f264f9d..09036337d 100644 --- a/Site/dashboard/test/Memory.php +++ b/Site/dashboard/test/Memory.php @@ -1,4 +1,11 @@ */ -require_once dirname(__FILE__) . "/../lib/JolExecOperation.php"; -require_once dirname(__FILE__) . "/../lib/JolRequest.php"; -require_once dirname(__FILE__) . "/../lib/JolReadOperation.php"; - class Memory { - private $base_url; + private string $base_url; public function __construct($base_url) { $this->base_url = $base_url; } - /** - * - * @return array Memory attributes - */ - public function attributes() { + public function attributes(): array { $req = new JolRequest($this->base_url); - $read = new JolReadOperation(array( - 'mbean' => 'java.lang:type=Memory', - 'attribute' => 'HeapMemoryUsage', - )); + $read = new JolReadOperation([ + 'mbean' => 'java.lang:type=Memory', + 'attribute' => 'HeapMemoryUsage', + ]); $req->add_operation($read); print "\n" . $req->curl_cli_equivalent() . "\n\n"; - $response = $req->invoke(); + $response = $req->invoke(); return $response[0]->value(); } public function bad_request() { $req = new JolRequest($this->base_url); - $read = new JolReadOperation(array( - 'mbean' => 'java.lang:type=Memory', - 'attribute' => 'BOGUS', - )); + $read = new JolReadOperation([ + 'mbean' => 'java.lang:type=Memory', + 'attribute' => 'BOGUS', + ]); $req->add_operation($read); $response = $req->invoke(); @@ -51,20 +50,14 @@ public function bad_request() { return $response[0]->value(); } - /** - * @param boolean true for success, false if error - */ - public function gc() { + public function gc(): bool { $req = new JolRequest($this->base_url); - $exec = new JolExecOperation(array( - 'mbean' => 'java.lang:type=Memory', - 'operation' => 'gc', - )); + $exec = new JolExecOperation([ + 'mbean' => 'java.lang:type=Memory', + 'operation' => 'gc', + ]); $req->add_operation($exec); $response = $req->invoke(); return !$response[0]->is_error(); } - } - -?> diff --git a/Site/dashboard/test/jmx_bridge_query_test.php b/Site/dashboard/test/jmx_bridge_query_test.php deleted file mode 100644 index 8739d6705..000000000 --- a/Site/dashboard/test/jmx_bridge_query_test.php +++ /dev/null @@ -1,121 +0,0 @@ -get('jol_base_url'); -$mbean_context = $c->get('context_name'); -$mbean_domain = $c->get('wdk_mbean_domain'); - -$q = new JmxBridgeQuery(); - -$mbean_path = ''; -$query_param_array = null; - - -$q->set_url($jol_base_url); - - -print "============ empty request ============ \n"; - -$q->set_query_param_array($query_param_array); - -$result = $q->execute(); - -print "json result " . $result->get_json_result(); - -/** -var_dump( $result->get_result_array() ); - -foreach($result as $a) { - print "#####\n"; var_dump($a); -} -**/ - -print "\n\n============ single request ============ \n"; - -$mbean_domain = 'org.apidb.wdk'; -$mbean_path = 'type=Log4J'; - -$query_param_array = array( - array('type' => 'read', - 'mbean' => "$mbean_domain:$mbean_path,context=$mbean_context", - 'attribute' => 'org.apache'), - ); - -$q->set_query_param_array($query_param_array); - -$result = $q->execute(); - - -foreach($result->get_result_array() as $r) { - print $r->to_string() . "\n################\n"; -} - -//var_dump( $result->get_result_array() ); - - -//print "json result " . $result->get_json_result(); - - - - -print "\n\n============ bulk request ============ \n"; - -$mbean_domain = 'org.apidb.wdk'; -$mbean_path = 'type=Log4J'; - -$query_param_array = array( - array('type' => 'read', - 'mbean' => "$mbean_domain:$mbean_path,context=$mbean_context", - 'attribute' => 'org.apache'), - array('type' => 'read', - 'mbean' => "$mbean_domain:$mbean_path,context=$mbean_context", - 'attribute' => 'org.gusdb'), - ); - -$q->set_query_param_array($query_param_array); - -$result = $q->execute(); - -foreach($result->get_result_array() as $r) { - print $r->to_string() . "\n################\n"; -} - - -//print "json result " . $result->get_json_result(); - - -print "\n\n============ bulk request with errors ======== \n"; - -$mbean_domain = 'org.apidb.wdk'; -$mbean_path = 'type=Log4J'; - -$query_param_array = array( - array('type' => 'read', - 'mbean' => "$mbean_domain:$mbean_path,context=$mbean_context", - 'attribute' => 'org.apache'), - array('type' => 'read', - 'mbean' => "$mbean_domain:$mbean_path,context=$mbean_context", - 'attribute' => 'BAD_ATTR'), - ); - -$q->set_query_param_array($query_param_array); - -$result = $q->execute(); - -foreach($result->get_result_array() as $r) { - print $r->to_string() . "\n################\n"; -} - -//var_dump( $result->get_result_array() ); - - -//print "json result " . $result->get_json_result(); - -?> \ No newline at end of file diff --git a/Site/dashboard/test/jol_request_test.php b/Site/dashboard/test/jol_request_test.php index c74afa126..4c74591e6 100644 --- a/Site/dashboard/test/jol_request_test.php +++ b/Site/dashboard/test/jol_request_test.php @@ -1,17 +1,26 @@ get('jol_base_url'); -$context_path = $c->get('context_name'); -print "========= empty read request ========== \n"; +echo "========= empty read request ========== \n"; $req = new JolRequest(); $req->set_base_url($jol_base_url); @@ -19,140 +28,124 @@ $read = new JolReadOperation(); try { $req->add_operation($read); - $response = $req->invoke(); -} catch (Exception $ex) { - print "OK - Correctly caught exception for invalid operation object.\n"; -} - -print "======================================= \n"; - -print "======== Jolokia agent version ======== \n"; -$req = new JolRequest(); -$req->set_base_url($jol_base_url); - -$read = new JolGenericOperation(array('type' => 'version')); -try { - $req->add_operation($read); - $response = $req->invoke(); - $data = $response[0]->value(); - print 'agent version: ' . $data{'agent'} . "\n"; -} catch (Exception $ex) { - print "FAIL - $ex\n"; + $req->invoke(); +} catch (Exception) { + echo "OK - Correctly caught exception for invalid operation object.\n"; } -print "======================================= \n"; +echo "======================================= \n"; -print "======== single read request (attribute + path) ======== \n"; +echo "======== single read request (attribute + path) ======== \n"; $req = new JolRequest(); $req->set_base_url($jol_base_url); -$read = new JolReadOperation(array( - 'mbean' => 'java.lang:type=Memory', - 'attribute' => 'HeapMemoryUsage', - 'path' => 'max', -)); - $req->add_operation($read); - $response = $req->invoke(); - $data = $response[0]->value(); - print "max mem: " . $data . "\n"; -print "======================================= \n"; +$read = new JolReadOperation([ + 'mbean' => 'java.lang:type=Memory', + 'attribute' => 'HeapMemoryUsage', + 'path' => 'max', +]); +$req->add_operation($read); +$response = $req->invoke(); +$data = $response[0]->value(); +echo "max mem: " . $data . "\n"; +echo "======================================= \n"; -print "======== single read request (attribute) ======== \n"; +echo "======== single read request (attribute) ======== \n"; $req = new JolRequest(); $req->set_base_url($jol_base_url); -$read = new JolReadOperation(array( - 'mbean' => 'java.lang:type=Memory', - 'attribute' => 'HeapMemoryUsage', -)); - $req->add_operation($read); - $response = $req->invoke(); - $data = $response[0]->value(); - print "max mem: " . $data{'max'} . "\n"; -print "======================================= \n"; +$read = new JolReadOperation([ + 'mbean' => 'java.lang:type=Memory', + 'attribute' => 'HeapMemoryUsage', +]); +$req->add_operation($read); +$response = $req->invoke(); +$data = $response[0]->value(); +echo "max mem: " . $data['max'] . "\n"; +echo "======================================= \n"; -print "======== single read request (whole mbean) ======== \n"; +echo "======== single read request (whole mbean) ======== \n"; $req = new JolRequest(); $req->set_base_url($jol_base_url); -$read = new JolReadOperation(array( - 'mbean' => 'java.lang:type=Memory', -)); - $req->add_operation($read); - $response = $req->invoke(); - $data = $response[0]->value(); - print "max mem: " . $data{'HeapMemoryUsage'}{'max'} . "\n"; -print "======================================= \n"; +$read = new JolReadOperation([ + 'mbean' => 'java.lang:type=Memory', +]); +$req->add_operation($read); +$response = $req->invoke(); +$data = $response[0]->value(); +echo "max mem: " . $data['HeapMemoryUsage']['max'] . "\n"; +echo "======================================= \n"; -print "======== single read request (path without attribute) ======== \n"; +echo "======== single read request (path without attribute) ======== \n"; $req = new JolRequest(); $req->set_base_url($jol_base_url); -$read = new JolReadOperation(array( - 'mbean' => 'java.lang:type=Memory', - 'path' => 'max', -)); +$read = new JolReadOperation([ + 'mbean' => 'java.lang:type=Memory', + 'path' => 'max', +]); try { $req->add_operation($read); $response = $req->invoke(); $data = $response[0]->value(); - print "max mem: " . $data{'HeapMemoryUsage'}{'max'} . "\n"; -} catch (Exception $ex) { - print "OK - Correctly caught invalid object exception\n"; + echo "max mem: " . $data['HeapMemoryUsage']['max'] . "\n"; +} catch (Exception) { + echo "OK - Correctly caught invalid object exception\n"; } -print "======================================= \n"; +echo "======================================= \n"; attributes(); -function attributes() { +function attributes(): void { global $jol_base_url; $req = new JolRequest(); $req->set_base_url($jol_base_url); - $read = new JolReadOperation(array( - 'mbean' => 'org.apidb.wdk:path=//localhost/toxo.mheiges,type=Database,role=AppDB', - )); - $exec = new JolExecOperation(array( - 'mbean' => 'org.apidb.wdk:type=Database,role=AppDB,path=//localhost/toxo.mheiges', - 'operation' => 'refresh', - 'arguments' => null, - )); - $read_error = new JolReadOperation(array( - 'mbean' => 'org.apidb.wdk:path=//localhost/toxo.mheiges,type=Database,role=AppDB', - 'attribute' => 'BOGUSATTR', - )); - $read_again = new JolReadOperation(array( - 'mbean' => 'org.apidb.wdk:path=//localhost/toxo.mheiges,type=Database,role=AppDB', - 'attribute' => 'system_date', - )); + $read = new JolReadOperation([ + 'mbean' => 'org.apidb.wdk:path=//localhost/toxo.mheiges,type=Database,role=AppDB', + ]); + $exec = new JolExecOperation([ + 'mbean' => 'org.apidb.wdk:type=Database,role=AppDB,path=//localhost/toxo.mheiges', + 'operation' => 'refresh', + 'arguments' => null, + ]); + $read_error = new JolReadOperation([ + 'mbean' => 'org.apidb.wdk:path=//localhost/toxo.mheiges,type=Database,role=AppDB', + 'attribute' => 'BOGUSATTR', + ]); + $read_again = new JolReadOperation([ + 'mbean' => 'org.apidb.wdk:path=//localhost/toxo.mheiges,type=Database,role=AppDB', + 'attribute' => 'system_date', + ]); $req->add_operation($read); $req->add_operation($exec); $req->add_operation($read_error); $req->add_operation($read_again); - print "ori json request: " . $req->http_postdata_as_json() . "\n"; + echo "ori json request: " . $req->http_postdata_as_json() . "\n"; $response = $req->invoke(); //return value_array = $result->value(); - //print "json result " . $response->get_json_result() . "\n"; + //echo "json result " . $response->get_json_result() . "\n"; $data = $response[0]->value(); - print "System Date 0: " . $data{'system_date'} . "\n"; - $response[2]->is_error() ? '' : print "System Date 2: " . $response[2]->value() . "\n"; - print "System Date 2: " . $response[3]->value() . "\n"; + + echo "System Date 0: " . $data['system_date'] . "\n"; + if (!$response[2]->is_error()) + echo "System Date 2: " . $response[2]->value() . "\n"; + echo "System Date 2: " . $response[3]->value() . "\n"; foreach ($response as $result) { if ($result->is_error()) { - print "ERROR " . $result->error_type() . "\n"; + echo "ERROR " . $result->error_type() . "\n"; continue; } $map = $result->value(); - print "map " . $map . "\n"; - print "request " . $result->request() . "\n"; - print "timestamp " . $result->timestamp() . "\n"; + echo "map " . $map . "\n"; + echo "request " . $result->request() . "\n"; + echo "timestamp " . $result->timestamp() . "\n"; } } - -?> \ No newline at end of file diff --git a/Site/dashboard/test/memory_class_test.php b/Site/dashboard/test/memory_class_test.php index 900d1326f..e90ab6b4c 100644 --- a/Site/dashboard/test/memory_class_test.php +++ b/Site/dashboard/test/memory_class_test.php @@ -1,13 +1,15 @@ -get('jol_base_url'); -print "jol_base_url $jol_base_url\n"; +echo "jol_base_url $jol_base_url\n"; $mem = new Memory($jol_base_url); @@ -18,13 +20,12 @@ $res = $mem->attributes(); var_dump($res); -print "\n"; +echo "\n"; -print "making a bad request...\n"; +echo "making a bad request...\n"; try { -print $mem->bad_request(). "\n"; +echo $mem->bad_request(). "\n"; } catch (Exception $ex) { - print "Caught exception (as expected):\n" . $ex->getMessage() . "\n"; + echo "Caught exception (as expected):\n" . $ex->getMessage() . "\n"; } -?> diff --git a/Site/dashboard/view/about.php b/Site/dashboard/view/about.php index a07df4dee..075f88e71 100644 --- a/Site/dashboard/view/about.php +++ b/Site/dashboard/view/about.php @@ -1,16 +1,11 @@ - -

    +

    About

    /dashboard is an instrumentation panel for EuPathDB websites. -

    +

    Additional Information

    • Background
    • diff --git a/Site/dashboard/view/apacheInfo.php b/Site/dashboard/view/apacheInfo.php index 03baa361d..59bfbb5e1 100644 --- a/Site/dashboard/view/apacheInfo.php +++ b/Site/dashboard/view/apacheInfo.php @@ -1,59 +1,50 @@ "; + echo "AttributeValue"; + $i = 0; + foreach ($array as $key => $value) { + if ($i++ % 2 == 0) { + $rowStyle = 'rowLight'; + } else { + $rowStyle = 'rowMedium'; + } + if ($key == 'Directive') { + echo ""; + } + echo ""; + if (is_array($value)) { + $value = implode(" "; + } + echo "
      $key", $value); + } + echo "$value
      "; +} ?> -

      Apache HTTP Server

      -

      expand all | collapse all

      +

      expand all | collapse all

      HTTP Headers ↑↓

      -

      Apache Environment ↑↓

      Apache Internals ↑↓

      - - -"; - print $tabledef; - print "AttributeValue"; - $i = 0; foreach ($array as $key => $value) { - if ($i++ % 2 == 0) { $rowStyle = 'rowLight'; } else { $rowStyle = 'rowMedium'; } - if ($key == 'Directive') { - print ""; - } - print ""; - if (is_array($value)) { - $value = implode(" "; - } else { - print " "; - } - } - print "
      $key", $value); - print "$value
      $value
      "; -} -?> diff --git a/Site/dashboard/view/buildInfo.php b/Site/dashboard/view/buildInfo.php index 639b3d8d9..0b832004b 100644 --- a/Site/dashboard/view/buildInfo.php +++ b/Site/dashboard/view/buildInfo.php @@ -1,12 +1,10 @@ get_data_map(); @@ -15,56 +13,54 @@ $flipped_stages = $stage_values->get_flipped_data_map(); $stages = $stage_values->get_data_map(); ?> -

      Website Stage

      - '; - print "Website Release Stage: " . $flipped_stages[$stage_value] . ' (' . $stage_value . ')'; - print '

      '; - + echo '

      '; + echo "Website Release Stage: " . $flipped_stages[$stage_value] . ' (' . $stage_value . ')'; + echo '

      '; + if (isset($_COOKIE["website_release_stage"])) { - print "

      The default stage for this site is overridden for this browser session by the cookie 'website_release_stage' and may differ + echo "

      The default stage for this site is overridden for this browser session by the cookie 'website_release_stage' and may differ from the actual stage. Delete this cookie or restart your browser to revert to the default.

      "; } - /** - // only development sites can change their stage on the fly - if ($stage_value == $stages['DEVELOPMENT'] || isset($_COOKIE["website_release_stage"])) { - print "

      change

      "; - } - */ + /** + * // only development sites can change their stage on the fly + * if ($stage_value == $stages['DEVELOPMENT'] || isset($_COOKIE["website_release_stage"])) { + * echo "

      change

      "; + * } + */ } else { - print "The 'WEBSITE_RELEASE_STAGE' environment variable is not set."; + echo "The 'WEBSITE_RELEASE_STAGE' environment variable is not set."; } - - ?> +?>

      Build State

      - Last build was for 'get('!Last.build.component') ?> - get('!Last.build.initialTarget') ?>' - on get('!Last.build.timestamp') ?> + Last build was for 'get('!Last.build.component') ?> + get('!Last.build.initialTarget') ?>' + on get('!Last.build.timestamp') ?> [?] + onmouseout="return nd();">[?]

      -Subversion working directories are recorded at build time. An incomplete build will result in an incomplete list. -Any subversion working directories in project_home that are not defined as dependencies in the GUS/Ant build will not be listed. -

      + Subversion working directories are recorded at build time. An incomplete build will result in an incomplete list. + Any subversion working directories in project_home that are not defined as dependencies in the GUS/Ant build will + not be listed. +

      Component Build Details ↑↓

      - - - diff --git a/Site/dashboard/view/configurationInfo.php b/Site/dashboard/view/configurationInfo.php index e7e1ad740..6f0afbd06 100644 --- a/Site/dashboard/view/configurationInfo.php +++ b/Site/dashboard/view/configurationInfo.php @@ -1,12 +1,9 @@ attributes(); $comment = $comment_config->attributes(); $properties = $properties_config->attributes(); - ?>

      Configuration

      -

      expand all | collapse all

      +

      expand all | collapse all

      WDK Model Configuration ↑↓

      -

      WDK Comments Configuration not available

      +

      WDK Comments Configuration not available

      -

      WDK Comments Configuration ↑↓

      -

      WDK Properties ↑↓

      -

      diff --git a/Site/dashboard/view/databaseInfo.php b/Site/dashboard/view/databaseInfo.php index 8eb5d2573..a694c399e 100644 --- a/Site/dashboard/view/databaseInfo.php +++ b/Site/dashboard/view/databaseInfo.php @@ -1,30 +1,15 @@ - - -

      - Connection pool activity -

      - attributes(); -$db_instances_str = $db_instances_attribs{'DbInstanceNames'}; +$db_instances_str = $db_instances_attribs['DbInstanceNames']; $db_names = explode(',', $db_instances_str); +?> + + +

      + Connection pool activity +

      +refresh(); - // TODO - put this warning near the refresh button where it is better noticed - if ( ! $success) {print "FAILED TO REFRESH";} - } +if (isset($_GET['refresh']) && $_GET['refresh'] == 1) { + $success = $database->refresh(); + + if (!$success) + echo "FAILED TO REFRESH"; +} - $adb = $database->attributes(); - $adb_aliases_ar = $ldap_resolver->resolve($adb{'service_name'}); - $tuning_status_attrs = $tuning_manager_status->attributes(); +$adb = $database->attributes(); +$adb_aliases_ar = $ldap_resolver->resolve($adb['service_name']); +$tuning_status_attrs = $tuning_manager_status->attributes(); - $workflow_status_attrs = $workflow_status->attributes(); +$workflow_status_attrs = $workflow_status->attributes(); ?> -

      Database

      +

      Database

      Identifiers: - - - - - - - - - - + + + + + + + + - - - - - + + - - - - - + + - - - - - + + - -
      IdentifierValue
      Service Name +
      IdentifierValue
      Service Name[?] -
      Instance Name + Instance Name[?] -
      Global Name + Global Name[?] -
      DB Unique Name + DB Unique Name[?]
      + +

      - Aliases (from LDAP):

      - Hosted on:
      - Size on disk: GB
      - Oracle Version:
      - Character encoding: + Aliases (from LDAP):

      + Hosted on:
      + Size on disk: GB
      + Oracle Version:
      + Character encoding:

      - Client login name:
      - Client connecting from:
      - Client OS user: + Client login name:
      + Client connecting from:
      + Client OS user:

      Available DBLinks: - - - - - - - +
      ownerdb_linkusernamehostcreated
      + + + + + + + + + + + + + + - - - - - - - - - -
      ownerdb_linkusernamehostcreated
      + +


      -Information on this page was last updated:
      +Information on this page was last updated:

      - - + +

      Custom Tuning

      Tuning Tables ↑↓

      -