diff --git a/search2/indexing/indexerCore.inc.php b/search2/indexing/indexerCore.inc.php index 9799fb3..61ecf8a 100755 --- a/search2/indexing/indexerCore.inc.php +++ b/search2/indexing/indexerCore.inc.php @@ -311,7 +311,7 @@ abstract class Indexer $default->log->error("resolveExtractor: cannot resolve $type"); return $class; } - if ($this->debug) $default->log->debug("resolveExtractor: Resolved '$class' from mime type '$type'."); + if ($this->debug) $default->log->debug(sprintf(_kt("resolveExtractor: Resolved '%s' from mime type '%s'."), $class, $type)); return $class; } @@ -758,11 +758,17 @@ abstract class Indexer protected abstract function indexDiscussion($docId); /** + * Diagnose the indexer. e.g. Check that the indexing server is running. + * + */ + public abstract function diagnose(); + + /** * Diagnose the extractors. * * @return array */ - public function diagnose() + public function diagnoseExtractors() { $diagnosis = $this->_diagnose($this->extractorPath, 'DocumentExtractor', 'Extractor.inc.php'); $diagnosis = array_merge($diagnosis, $this->_diagnose($this->hookPath, 'Hook', 'Hook.inc.php')); @@ -789,7 +795,7 @@ abstract class Indexer { if (substr($file,$extlen) != $extension) { - $default->log->error("diagnose: '$file' does not have extension '$extension'."); + $default->log->error(sprintf(_kt("diagnose: '%s' does not have extension '%s'."), $file, $extension)); continue; } @@ -798,21 +804,21 @@ abstract class Indexer $class = substr($file, 0, -8); if (!class_exists($class)) { - $default->log->error("diagnose: class '$class' does not exist."); + $default->log->error(sprintf(_kt("diagnose: class '%s' does not exist."), $class)); continue; } $extractor = new $class(); if (!is_a($extractor, $baseclass)) { - $default->log->error("diagnose(): '$class' is not of type DocumentExtractor"); + $default->log->error(sprintf(_kt("diagnose(): '%s' is not of type DocumentExtractor"), $class)); continue; } $types = $extractor->getSupportedMimeTypes(); if (empty($types)) { - if ($this->debug) $default->log->debug("diagnose: class '$class' does not support any types."); + if ($this->debug) $default->log->debug(sprintf(_kt("diagnose: class '%s' does not support any types."), $class)); continue; } diff --git a/search2/indexing/indexers/JavaXMLRPCLuceneIndexer.inc.php b/search2/indexing/indexers/JavaXMLRPCLuceneIndexer.inc.php index dc23bf6..bbad119 100755 --- a/search2/indexing/indexers/JavaXMLRPCLuceneIndexer.inc.php +++ b/search2/indexing/indexers/JavaXMLRPCLuceneIndexer.inc.php @@ -149,5 +149,22 @@ class JavaXMLRPCLuceneIndexer extends Indexer return $results; } + public function diagnose() + { + $config =& KTConfig::getSingleton(); + + $ooHost = $config->get('openoffice/host', 'localhost'); + $ooPort = $config->get('openoffice/port', 8100); + $connection = @fsockopen($ooHost, $ooPort,$errno, $errstr, 2); + if (false === $connection) + { + return _kt('Cannot connect to openoffice host'); + } + fclose($connection); + + return null; + } + + } ?> \ No newline at end of file diff --git a/search2/indexing/indexers/PHPLuceneIndexer.inc.php b/search2/indexing/indexers/PHPLuceneIndexer.inc.php index 60602e6..d1e2fa7 100755 --- a/search2/indexing/indexers/PHPLuceneIndexer.inc.php +++ b/search2/indexing/indexers/PHPLuceneIndexer.inc.php @@ -14,12 +14,21 @@ class PHPLuceneIndexer extends Indexer * * @param boolean $create Optional. If true, the lucene index will be recreated. */ - public function __construct() + public function __construct($catchException=false) { parent::__construct(); $config =& KTConfig::getSingleton(); $indexPath = $config->get('indexer/luceneDirectory'); - $this->lucene = new Zend_Search_Lucene($indexPath, false); + try + { + $this->lucene = new Zend_Search_Lucene($indexPath, false); + } + catch(Exception $ex) + { + $this->lucene = null; + if (!$catchException) + throw $ex; + } } /** @@ -65,7 +74,7 @@ class PHPLuceneIndexer extends Indexer if (!is_file($textfile)) { - $default->log->error("Attempting to index $docid $textfile but it is not available."); + $default->log->error(sprintf(_kt("Attempting to index %d %s but it is not available."),$docid, $textfile)); return false; } @@ -89,7 +98,7 @@ class PHPLuceneIndexer extends Indexer if (!is_file($textfile)) { - $default->log->error("Attempting to index $docid $textfile but it is not available."); + $default->log->error(sprintf(_kt("Attempting to index %d %s but it is not available."),$docid, $textfile)); return false; } @@ -180,5 +189,14 @@ class PHPLuceneIndexer extends Indexer } return $results; } + + public function diagnose() + { + if ($this->lucene == null) + { + return _kt("The lucene index has not been initialised correctly. Please review the documentation on how to setup the indexing."); + } + return null; + } } ?> \ No newline at end of file