ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilLuceneRPCAdapter.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 
33 include_once 'Services/WebServices/RPC/classes/class.ilRPCServerAdapter.php';
34 
36 {
37  var $mode = '';
38  var $files = array();
39  var $query_str = '';
40  var $filter = '';
41 
42 
43  function ilLuceneRPCAdapter()
44  {
46  }
47 
48  function setMode($a_mode)
49  {
50  $this->mode = $a_mode;
51  }
52  function getMode()
53  {
54  return $this->mode;
55  }
56  function setFiles(&$files)
57  {
58  $this->files =& $files;
59  }
60  function &getFiles()
61  {
62  return $this->files ? $this->files : array();
63  }
64  function setHTLMs(&$htlms)
65  {
66  $this->htlms = $htlms;
67  }
68  function &getHTLMs()
69  {
70  return $this->htlms;
71  }
72 
73  function setQueryString($a_str)
74  {
75  $this->query_str = $a_str;
76  }
77  function getQueryString()
78  {
79  return $this->query_str;
80  }
81 
82  function setSearchFilter($a_filter)
83  {
84  $this->filter = $a_filter;
85  }
86  function getSearchFilter()
87  {
88  return $this->filter ? $this->filter : array();
89  }
90 
96  function __getClientId()
97  {
98  global $ilias;
99 
100  // TODO: handle problem if nic_key isn't set
101  return $ilias->getSetting('nic_key').'_'.CLIENT_ID;
102  }
103 
104 
105 
106  function send()
107  {
108  $this->__initClient();
109  switch($this->getMode())
110  {
111  case 'ping':
112  $this->__preparePingParams();
113  break;
114 
115  case 'file':
116  $this->__prepareIndexFileParams();
117  break;
118 
119  case 'query':
120  $this->__prepareQueryParams();
121  break;
122 
123  case 'htlm':
124  $this->__prepareIndexHTLMParams();
125  break;
126 
127  case 'flush':
128  $this->__prepareFlushIndex();
129  break;
130 
131  default:
132  $this->log->write('ilLuceneRPCHandler(): No valid mode given');
133  return false;
134 
135  }
136  return parent::send();
137  }
138  // PRIVATE
140  {
141  $this->setResponseTimeout(5);
142  $filter = array();
143  foreach($this->getSearchFilter() as $obj_type)
144  {
145  $filter[] = new XML_RPC_Value($obj_type,'string');
146  }
147  $this->__initMessage('Searcher.ilSearch',array(new XML_RPC_Value($this->__getClientId(),"string"),
148  new XML_RPC_Value($this->getQueryString(),"string"),
149  new XML_RPC_Value($filter,'array')));
150 
151  return true;
152  }
153 
155  {
156  $this->setResponseTimeout(5);
157  $this->__initMessage('Searcher.ilPing',array(new XML_RPC_Value($this->__getClientId(),"string")));
158 
159  return true;
160  }
161 
163  {
164  $this->setResponseTimeout(5);
165  foreach($this->getFiles() as $obj_id => $fname)
166  {
167  $struct[$obj_id] = new XML_RPC_Value($fname,"string");
168  }
169  $params = array(new XML_RPC_Value($this->__getClientId(),"string"),
170  new XML_RPC_Value($struct,"struct"));
171 
172  $this->__initMessage('Indexer.ilFileIndexer',$params);
173 
174  return true;
175  }
176 
178  {
179  $this->setResponseTimeout(5);
180  foreach($this->getHTLMs() as $obj_id => $fname)
181  {
182  $struct[$obj_id] = new XML_RPC_Value($fname,"string");
183  }
184 
185  $this->__initMessage('Indexer.ilHTLMIndexer',array(new XML_RPC_Value($this->__getClientId(),"string"),
186  new XML_RPC_Value($struct,"struct")));
187 
188  return true;
189  }
191  {
192  $this->setResponseTimeout(5);
193  $this->__initMessage('Indexer.ilClearIndex',array(new XML_RPC_Value($this->__getClientId(),"string")));
194 
195  return true;
196  }
197 }
198 ?>