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,7 +311,7 @@ abstract class Indexer
311 $default->log->error("resolveExtractor: cannot resolve $type"); 311 $default->log->error("resolveExtractor: cannot resolve $type");
312 return $class; 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 return $class; 315 return $class;
316 } 316 }
317 317
@@ -758,11 +758,17 @@ abstract class Indexer @@ -758,11 +758,17 @@ abstract class Indexer
758 protected abstract function indexDiscussion($docId); 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 * Diagnose the extractors. 767 * Diagnose the extractors.
762 * 768 *
763 * @return array 769 * @return array
764 */ 770 */
765 - public function diagnose() 771 + public function diagnoseExtractors()
766 { 772 {
767 $diagnosis = $this->_diagnose($this->extractorPath, 'DocumentExtractor', 'Extractor.inc.php'); 773 $diagnosis = $this->_diagnose($this->extractorPath, 'DocumentExtractor', 'Extractor.inc.php');
768 $diagnosis = array_merge($diagnosis, $this->_diagnose($this->hookPath, 'Hook', 'Hook.inc.php')); 774 $diagnosis = array_merge($diagnosis, $this->_diagnose($this->hookPath, 'Hook', 'Hook.inc.php'));
@@ -789,7 +795,7 @@ abstract class Indexer @@ -789,7 +795,7 @@ abstract class Indexer
789 { 795 {
790 if (substr($file,$extlen) != $extension) 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 continue; 799 continue;
794 } 800 }
795 801
@@ -798,21 +804,21 @@ abstract class Indexer @@ -798,21 +804,21 @@ abstract class Indexer
798 $class = substr($file, 0, -8); 804 $class = substr($file, 0, -8);
799 if (!class_exists($class)) 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 continue; 808 continue;
803 } 809 }
804 810
805 $extractor = new $class(); 811 $extractor = new $class();
806 if (!is_a($extractor, $baseclass)) 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 continue; 815 continue;
810 } 816 }
811 817
812 $types = $extractor->getSupportedMimeTypes(); 818 $types = $extractor->getSupportedMimeTypes();
813 if (empty($types)) 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 continue; 822 continue;
817 } 823 }
818 824
search2/indexing/indexers/JavaXMLRPCLuceneIndexer.inc.php
@@ -149,5 +149,22 @@ class JavaXMLRPCLuceneIndexer extends Indexer @@ -149,5 +149,22 @@ class JavaXMLRPCLuceneIndexer extends Indexer
149 return $results; 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 \ No newline at end of file 171 \ No newline at end of file
search2/indexing/indexers/PHPLuceneIndexer.inc.php
@@ -14,12 +14,21 @@ class PHPLuceneIndexer extends Indexer @@ -14,12 +14,21 @@ class PHPLuceneIndexer extends Indexer
14 * 14 *
15 * @param boolean $create Optional. If true, the lucene index will be recreated. 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 parent::__construct(); 19 parent::__construct();
20 $config =& KTConfig::getSingleton(); 20 $config =& KTConfig::getSingleton();
21 $indexPath = $config->get('indexer/luceneDirectory'); 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,7 +74,7 @@ class PHPLuceneIndexer extends Indexer
65 74
66 if (!is_file($textfile)) 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 return false; 78 return false;
70 } 79 }
71 80
@@ -89,7 +98,7 @@ class PHPLuceneIndexer extends Indexer @@ -89,7 +98,7 @@ class PHPLuceneIndexer extends Indexer
89 98
90 if (!is_file($textfile)) 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 return false; 102 return false;
94 } 103 }
95 104
@@ -180,5 +189,14 @@ class PHPLuceneIndexer extends Indexer @@ -180,5 +189,14 @@ class PHPLuceneIndexer extends Indexer
180 } 189 }
181 return $results; 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 \ No newline at end of file 203 \ No newline at end of file