ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 {
20  protected $timeout = 60;
21 
22  public function getId()
23  {
24  return "src_lucene_indexer";
25  }
26 
27  public function getTitle()
28  {
29  global $lng;
30 
31  return $lng->txt("cron_lucene_index");
32  }
33 
34  public function getDescription()
35  {
36  global $lng;
37 
38  return $lng->txt("cron_lucene_index_info");
39  }
40 
41  public function getDefaultScheduleType()
42  {
43  return self::SCHEDULE_TYPE_DAILY;
44  }
45 
46  public function getDefaultScheduleValue()
47  {
48  return;
49  }
50 
51  public function hasAutoActivation()
52  {
53  return false;
54  }
55 
56  public function hasFlexibleSchedule()
57  {
58  return true;
59  }
60 
61  public function run()
62  {
63  global $ilSetting;
64 
66  $error_message = null;
67 
68  try
69  {
70  include_once './Services/WebServices/RPC/classes/class.ilRpcClientFactory.php';
71  ilRpcClientFactory::factory('RPCIndexHandler',60)->index(
72  CLIENT_ID.'_'.$ilSetting->get('inst_id',0),
73  true
74  );
75  }
76  catch(Exception $e)
77  {
78  $error_message = $e->getMessage();
79 
80  if($e instanceof ilRpcClientException && $e->getCode() == 28)
81  {
82  ilLoggerFactory::getLogger('src')->info('Connection timed out after ' . $this->timeout . ' seconds. '.
83  'Indexing will continoue without a proper return message. View ilServer log if you think there are problems while indexing.');
84  $error_message = null;
85  }
86 
87  }
88 
89  $result = new ilCronJobResult();
90  if($error_message)
91  {
92  // #16035 - currently no way to discern the severity of the exception
93  $result->setMessage($error_message);
95  }
96  else
97  {
99  }
100  $result->setStatus($status);
101  return $result;
102  }
103 
104 
110  public static function updateLuceneIndex($a_obj_ids)
111  {
112  global $ilSetting;
113  include_once './Services/Search/classes/class.ilSearchSettings.php';
114  if(!ilSearchSettings::getInstance()->isLuceneUserSearchEnabled())
115  {
116  return false;
117  }
118 
119  try
120  {
121  ilLoggerFactory::getLogger('src')->info('Lucene update index call BEGIN --- ');
122 
123  include_once './Services/WebServices/RPC/classes/class.ilRpcClientFactory.php';
124  ilRpcClientFactory::factory('RPCIndexHandler', 1)->indexObjects(
125  CLIENT_ID.'_'.$ilSetting->get('inst_id',0),
126  $a_obj_ids
127  );
128  ilLoggerFactory::getLogger('src')->info('Lucene update index call --- END');
129  }
130  catch(Exception $e)
131  {
132  $error_message = $e->getMessage();
133  ilLoggerFactory::getLogger('src')->error($error_message);
134  return false;
135  }
136 
137  return true;
138  }
139 
140 }
141 
142 ?>
$result
Cron job application base class.
static factory($a_package, $a_timeout=0)
Creates an ilRpcClient instance to our ilServer.
static updateLuceneIndex($a_obj_ids)
Update lucene index.
Class ilRpcClientException.
global $ilSetting
Definition: privfeed.php:17
global $lng
Definition: privfeed.php:17
static getLogger($a_component_id)
Get component logger.
Cron job result data container.