Commit 84df8a23eace823aff707d81f47ec68faeb10c4c

Authored by conradverm
1 parent c5f59e87

KTS-673

"The search algorithm needs some work"
Updated. Internationalisation

KTS-2407
"The text extractor diagnostics dashlet should also diagnose if the indexer is operational."
Implemented. Made provision for distinction between extractor and indexer diagnosis.

Committed By: Conrad Vermeulen
Reviewed By: Kevin Fourie

git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@7285 c91229c3-7414-0410-bfa2-8a42b809f60b
search2/indexing/indexerCore.inc.php
... ... @@ -311,7 +311,7 @@ abstract class Indexer
311 311 $default->log->error("resolveExtractor: cannot resolve $type");
312 312 return $class;
313 313 }
314   - if ($this->debug) $default->log->debug("resolveExtractor: Resolved '$class' from mime type '$type'.");
  314 + if ($this->debug) $default->log->debug(sprintf(_kt("resolveExtractor: Resolved '%s' from mime type '%s'."), $class, $type));
315 315 return $class;
316 316 }
317 317  
... ... @@ -758,11 +758,17 @@ abstract class Indexer
758 758 protected abstract function indexDiscussion($docId);
759 759  
760 760 /**
  761 + * Diagnose the indexer. e.g. Check that the indexing server is running.
  762 + *
  763 + */
  764 + public abstract function diagnose();
  765 +
  766 + /**
761 767 * Diagnose the extractors.
762 768 *
763 769 * @return array
764 770 */
765   - public function diagnose()
  771 + public function diagnoseExtractors()
766 772 {
767 773 $diagnosis = $this->_diagnose($this->extractorPath, 'DocumentExtractor', 'Extractor.inc.php');
768 774 $diagnosis = array_merge($diagnosis, $this->_diagnose($this->hookPath, 'Hook', 'Hook.inc.php'));
... ... @@ -789,7 +795,7 @@ abstract class Indexer
789 795 {
790 796 if (substr($file,$extlen) != $extension)
791 797 {
792   - $default->log->error("diagnose: '$file' does not have extension '$extension'.");
  798 + $default->log->error(sprintf(_kt("diagnose: '%s' does not have extension '%s'."), $file, $extension));
793 799 continue;
794 800 }
795 801  
... ... @@ -798,21 +804,21 @@ abstract class Indexer
798 804 $class = substr($file, 0, -8);
799 805 if (!class_exists($class))
800 806 {
801   - $default->log->error("diagnose: class '$class' does not exist.");
  807 + $default->log->error(sprintf(_kt("diagnose: class '%s' does not exist."), $class));
802 808 continue;
803 809 }
804 810  
805 811 $extractor = new $class();
806 812 if (!is_a($extractor, $baseclass))
807 813 {
808   - $default->log->error("diagnose(): '$class' is not of type DocumentExtractor");
  814 + $default->log->error(sprintf(_kt("diagnose(): '%s' is not of type DocumentExtractor"), $class));
809 815 continue;
810 816 }
811 817  
812 818 $types = $extractor->getSupportedMimeTypes();
813 819 if (empty($types))
814 820 {
815   - if ($this->debug) $default->log->debug("diagnose: class '$class' does not support any types.");
  821 + if ($this->debug) $default->log->debug(sprintf(_kt("diagnose: class '%s' does not support any types."), $class));
816 822 continue;
817 823 }
818 824  
... ...
search2/indexing/indexers/JavaXMLRPCLuceneIndexer.inc.php
... ... @@ -149,5 +149,22 @@ class JavaXMLRPCLuceneIndexer extends Indexer
149 149 return $results;
150 150 }
151 151  
  152 + public function diagnose()
  153 + {
  154 + $config =& KTConfig::getSingleton();
  155 +
  156 + $ooHost = $config->get('openoffice/host', 'localhost');
  157 + $ooPort = $config->get('openoffice/port', 8100);
  158 + $connection = @fsockopen($ooHost, $ooPort,$errno, $errstr, 2);
  159 + if (false === $connection)
  160 + {
  161 + return _kt('Cannot connect to openoffice host');
  162 + }
  163 + fclose($connection);
  164 +
  165 + return null;
  166 + }
  167 +
  168 +
152 169 }
153 170 ?>
154 171 \ No newline at end of file
... ...
search2/indexing/indexers/PHPLuceneIndexer.inc.php
... ... @@ -14,12 +14,21 @@ class PHPLuceneIndexer extends Indexer
14 14 *
15 15 * @param boolean $create Optional. If true, the lucene index will be recreated.
16 16 */
17   - public function __construct()
  17 + public function __construct($catchException=false)
18 18 {
19 19 parent::__construct();
20 20 $config =& KTConfig::getSingleton();
21 21 $indexPath = $config->get('indexer/luceneDirectory');
22   - $this->lucene = new Zend_Search_Lucene($indexPath, false);
  22 + try
  23 + {
  24 + $this->lucene = new Zend_Search_Lucene($indexPath, false);
  25 + }
  26 + catch(Exception $ex)
  27 + {
  28 + $this->lucene = null;
  29 + if (!$catchException)
  30 + throw $ex;
  31 + }
23 32 }
24 33  
25 34 /**
... ... @@ -65,7 +74,7 @@ class PHPLuceneIndexer extends Indexer
65 74  
66 75 if (!is_file($textfile))
67 76 {
68   - $default->log->error("Attempting to index $docid $textfile but it is not available.");
  77 + $default->log->error(sprintf(_kt("Attempting to index %d %s but it is not available."),$docid, $textfile));
69 78 return false;
70 79 }
71 80  
... ... @@ -89,7 +98,7 @@ class PHPLuceneIndexer extends Indexer
89 98  
90 99 if (!is_file($textfile))
91 100 {
92   - $default->log->error("Attempting to index $docid $textfile but it is not available.");
  101 + $default->log->error(sprintf(_kt("Attempting to index %d %s but it is not available."),$docid, $textfile));
93 102 return false;
94 103 }
95 104  
... ... @@ -180,5 +189,14 @@ class PHPLuceneIndexer extends Indexer
180 189 }
181 190 return $results;
182 191 }
  192 +
  193 + public function diagnose()
  194 + {
  195 + if ($this->lucene == null)
  196 + {
  197 + return _kt("The lucene index has not been initialised correctly. Please review the documentation on how to setup the indexing.");
  198 + }
  199 + return null;
  200 + }
183 201 }
184 202 ?>
185 203 \ No newline at end of file
... ...