ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilLuceneIndexer.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once "Services/Cron/classes/class.ilCronJob.php";
5 
16 {
17  public function getId()
18  {
19  return "src_lucene_indexer";
20  }
21 
22  public function getTitle()
23  {
24  global $lng;
25 
26  return $lng->txt("cron_lucene_index");
27  }
28 
29  public function getDescription()
30  {
31  global $lng;
32 
33  return $lng->txt("cron_lucene_index_info");
34  }
35 
36  public function getDefaultScheduleType()
37  {
38  return self::SCHEDULE_TYPE_DAILY;
39  }
40 
41  public function getDefaultScheduleValue()
42  {
43  return;
44  }
45 
46  public function hasAutoActivation()
47  {
48  return false;
49  }
50 
51  public function hasFlexibleSchedule()
52  {
53  return true;
54  }
55 
56  public function run()
57  {
58  global $ilSetting;
59 
61  $error_message = null;
62 
63  try
64  {
65  include_once './Services/WebServices/RPC/classes/class.ilRpcClientFactory.php';
66  ilRpcClientFactory::factory('RPCIndexHandler')->index(
67  CLIENT_ID.'_'.$ilSetting->get('inst_id',0),
68  true
69  );
70  }
71  catch(XML_RPC2_FaultException $e)
72  {
73  $error_message = $e->getMessage();
74  }
75  catch(Exception $e)
76  {
77  $error_message = $e->getMessage();
78  }
79 
80  $result = new ilCronJobResult();
81  if($error_message)
82  {
83  // #16035 - currently no way to discern the severity of the exception
84  $result->setMessage($error_message);
86  }
87  else
88  {
90  }
91  $result->setStatus($status);
92  return $result;
93  }
94 
95 
100  public static function updateLuceneIndex($a_obj_ids)
101  {
102  global $ilSetting;
103 
104  include_once './Services/Search/classes/class.ilSearchSettings.php';
105  if(!ilSearchSettings::getInstance()->isLuceneUserSearchEnabled())
106  {
107  return false;
108  }
109 
110  try
111  {
112  ilLoggerFactory::getLogger('src')->info('Lucene update index call BEGIN --- ');
113 
114  include_once './Services/WebServices/RPC/classes/class.ilRpcClientFactory.php';
115  ilRpcClientFactory::factory('RPCIndexHandler')->indexObjects(
116  CLIENT_ID.'_'.$ilSetting->get('inst_id',0),
117  $a_obj_ids
118  );
119  ilLoggerFactory::getLogger('src')->info('Lucene update index call --- END');
120  }
121  catch(XML_RPC2_FaultException $e)
122  {
123  $error_message = $e->getMessage();
124  ilLoggerFactory::getLogger('src')->critical($error_message);
125  }
126  catch(Exception $e)
127  {
128  $error_message = $e->getMessage();
129  ilLoggerFactory::getLogger('src')->error($error_message);
130  }
131 
132  }
133 
134 }
135 
136 ?>
$result
Cron job application base class.
static updateLuceneIndex($a_obj_ids)
Update lucene index.
static factory($a_package)
Create an XML_RPC2 client instance.
global $ilSetting
Definition: privfeed.php:40
global $lng
Definition: privfeed.php:40
static getLogger($a_component_id)
Get component logger.
Cron job result data container.