ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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  include_once './Services/WebServices/RPC/classes/class.ilRpcClientFactory.php';
70  ilRpcClientFactory::factory('RPCIndexHandler', 60)->index(
71  CLIENT_ID . '_' . $ilSetting->get('inst_id', 0),
72  true
73  );
74  } catch (Exception $e) {
75  $error_message = $e->getMessage();
76 
77  if ($e instanceof ilRpcClientException && $e->getCode() == 28) {
78  ilLoggerFactory::getLogger('src')->info('Connection timed out after ' . $this->timeout . ' seconds. ' .
79  'Indexing will continoue without a proper return message. View ilServer log if you think there are problems while indexing.');
80  $error_message = null;
81  }
82  }
83 
84  $result = new ilCronJobResult();
85  if ($error_message) {
86  // #16035 - currently no way to discern the severity of the exception
87  $result->setMessage($error_message);
89  } else {
91  }
92  $result->setStatus($status);
93  return $result;
94  }
95 
96 
102  public static function updateLuceneIndex($a_obj_ids)
103  {
104  global $ilSetting;
105  include_once './Services/Search/classes/class.ilSearchSettings.php';
106  if (!ilSearchSettings::getInstance()->isLuceneUserSearchEnabled()) {
107  return false;
108  }
109 
110  try {
111  ilLoggerFactory::getLogger('src')->info('Lucene update index call BEGIN --- ');
112 
113  include_once './Services/WebServices/RPC/classes/class.ilRpcClientFactory.php';
114  ilRpcClientFactory::factory('RPCIndexHandler', 1)->indexObjects(
115  CLIENT_ID . '_' . $ilSetting->get('inst_id', 0),
116  $a_obj_ids
117  );
118  ilLoggerFactory::getLogger('src')->info('Lucene update index call --- END');
119  } catch (Exception $e) {
120  $error_message = $e->getMessage();
121  ilLoggerFactory::getLogger('src')->error($error_message);
122  return false;
123  }
124 
125  return true;
126  }
127 }
$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.