Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00033 include_once 'Services/WebServices/RPC/classes/class.ilRPCServerAdapter.php';
00034
00035 class ilLuceneRPCAdapter extends ilRPCServerAdapter
00036 {
00037 var $mode = '';
00038 var $files = array();
00039 var $query_str = '';
00040 var $filter = '';
00041
00042
00043 function ilLuceneRPCAdapter()
00044 {
00045 parent::ilRPCServerAdapter();
00046 }
00047
00048 function setMode($a_mode)
00049 {
00050 $this->mode = $a_mode;
00051 }
00052 function getMode()
00053 {
00054 return $this->mode;
00055 }
00056 function setFiles(&$files)
00057 {
00058 $this->files =& $files;
00059 }
00060 function &getFiles()
00061 {
00062 return $this->files ? $this->files : array();
00063 }
00064 function setHTLMs(&$htlms)
00065 {
00066 $this->htlms = $htlms;
00067 }
00068 function &getHTLMs()
00069 {
00070 return $this->htlms;
00071 }
00072
00073 function setQueryString($a_str)
00074 {
00075 $this->query_str = $a_str;
00076 }
00077 function getQueryString()
00078 {
00079 return $this->query_str;
00080 }
00081
00082 function setSearchFilter($a_filter)
00083 {
00084 $this->filter = $a_filter;
00085 }
00086 function getSearchFilter()
00087 {
00088 return $this->filter ? $this->filter : array();
00089 }
00090
00096 function __getClientId()
00097 {
00098 global $ilias;
00099
00100
00101 return $ilias->getSetting('nic_key').'_'.CLIENT_ID;
00102 }
00103
00104
00105
00106 function send()
00107 {
00108 $this->__initClient();
00109 switch($this->getMode())
00110 {
00111 case 'ping':
00112 $this->__preparePingParams();
00113 break;
00114
00115 case 'file':
00116 $this->__prepareIndexFileParams();
00117 break;
00118
00119 case 'query':
00120 $this->__prepareQueryParams();
00121 break;
00122
00123 case 'htlm':
00124 $this->__prepareIndexHTLMParams();
00125 break;
00126
00127 case 'flush':
00128 $this->__prepareFlushIndex();
00129 break;
00130
00131 default:
00132 $this->log->write('ilLuceneRPCHandler(): No valid mode given');
00133 return false;
00134
00135 }
00136 return parent::send();
00137 }
00138
00139 function __prepareQueryParams()
00140 {
00141 $this->setResponseTimeout(5);
00142 $filter = array();
00143 foreach($this->getSearchFilter() as $obj_type)
00144 {
00145 $filter[] = new XML_RPC_Value($obj_type,'string');
00146 }
00147 $this->__initMessage('Searcher.ilSearch',array(new XML_RPC_Value($this->__getClientId(),"string"),
00148 new XML_RPC_Value($this->getQueryString(),"string"),
00149 new XML_RPC_Value($filter,'array')));
00150
00151 return true;
00152 }
00153
00154 function __preparePingParams()
00155 {
00156 $this->setResponseTimeout(5);
00157 $this->__initMessage('Searcher.ilPing',array(new XML_RPC_Value($this->__getClientId(),"string")));
00158
00159 return true;
00160 }
00161
00162 function __prepareIndexFileParams()
00163 {
00164 $this->setResponseTimeout(5);
00165 foreach($this->getFiles() as $obj_id => $fname)
00166 {
00167 $struct[$obj_id] = new XML_RPC_Value($fname,"string");
00168 }
00169 $params = array(new XML_RPC_Value($this->__getClientId(),"string"),
00170 new XML_RPC_Value($struct,"struct"));
00171
00172 $this->__initMessage('Indexer.ilFileIndexer',$params);
00173
00174 return true;
00175 }
00176
00177 function __prepareIndexHTLMParams()
00178 {
00179 $this->setResponseTimeout(5);
00180 foreach($this->getHTLMs() as $obj_id => $fname)
00181 {
00182 $struct[$obj_id] = new XML_RPC_Value($fname,"string");
00183 }
00184
00185 $this->__initMessage('Indexer.ilHTLMIndexer',array(new XML_RPC_Value($this->__getClientId(),"string"),
00186 new XML_RPC_Value($struct,"struct")));
00187
00188 return true;
00189 }
00190 function __prepareFlushIndex()
00191 {
00192 $this->setResponseTimeout(5);
00193 $this->__initMessage('Indexer.ilClearIndex',array(new XML_RPC_Value($this->__getClientId(),"string")));
00194
00195 return true;
00196 }
00197 }
00198 ?>