• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

Services/Search/classes/Lucene/class.ilLuceneRPCAdapter.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2001 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
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                 // TODO: handle problem if nic_key isn't set
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         // PRIVATE
00139         function __prepareQueryParams()
00140         {
00141                 $filter = array();
00142                 foreach($this->getSearchFilter() as $obj_type)
00143                 {
00144                         $filter[] = new XML_RPC_Value($obj_type,'string');
00145                 }
00146                 $this->__initMessage('Searcher.ilSearch',array(new XML_RPC_Value($this->__getClientId(),"string"),
00147                                                                                                            new XML_RPC_Value($this->getQueryString(),"string"),
00148                                                                                                            new XML_RPC_Value($filter,'array')));
00149 
00150                 return true;
00151         }
00152 
00153         function __preparePingParams()
00154         {
00155                 $this->__initMessage('Searcher.ilPing',array(new XML_RPC_Value($this->__getClientId(),"string")));
00156 
00157                 return true;
00158         }
00159 
00160         function __prepareIndexFileParams()
00161         {
00162                 foreach($this->getFiles() as $obj_id => $fname)
00163                 {
00164                         $struct[$obj_id] = new XML_RPC_Value($fname,"string");
00165                 }
00166                 $params = array(new XML_RPC_Value($this->__getClientId(),"string"),
00167                                                 new XML_RPC_Value($struct,"struct"));
00168 
00169                 $this->__initMessage('Indexer.ilFileIndexer',$params);
00170 
00171                 return true;
00172         }
00173 
00174         function __prepareIndexHTLMParams()
00175         {
00176                 foreach($this->getHTLMs() as $obj_id => $fname)
00177                 {
00178                         $struct[$obj_id] = new XML_RPC_Value($fname,"string");
00179                 }
00180 
00181                 $this->__initMessage('Indexer.ilHTLMIndexer',array(new XML_RPC_Value($this->__getClientId(),"string"),
00182                                                                                                                    new XML_RPC_Value($struct,"struct")));
00183 
00184                 return true;
00185         }
00186         function __prepareFlushIndex()
00187         {
00188 
00189                 $this->__initMessage('Indexer.ilClearIndex',array(new XML_RPC_Value($this->__getClientId(),"string")));
00190 
00191                 return true;
00192         }
00193 }
00194 ?>

Generated on Fri Dec 13 2013 10:18:31 for ILIAS Release_3_5_x_branch .rev 46805 by  doxygen 1.7.1