ILIAS  release_7 Revision v7.30-3-g800a261c036
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
4include_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 $DIC;
30
31 $lng = $DIC['lng'];
32
33 return $lng->txt("cron_lucene_index");
34 }
35
36 public function getDescription()
37 {
38 global $DIC;
39
40 $lng = $DIC['lng'];
41
42 return $lng->txt("cron_lucene_index_info");
43 }
44
45 public function getDefaultScheduleType()
46 {
48 }
49
50 public function getDefaultScheduleValue()
51 {
52 return;
53 }
54
55 public function hasAutoActivation()
56 {
57 return false;
58 }
59
60 public function hasFlexibleSchedule()
61 {
62 return true;
63 }
64
65 public function run()
66 {
67 global $DIC;
68
69 $ilSetting = $DIC['ilSetting'];
70
72 $error_message = null;
73
74 try {
75 include_once './Services/WebServices/RPC/classes/class.ilRpcClientFactory.php';
76 ilRpcClientFactory::factory('RPCIndexHandler', 60)->index(
77 CLIENT_ID . '_' . $ilSetting->get('inst_id', 0),
78 true
79 );
80 } catch (Exception $e) {
81 $error_message = $e->getMessage();
82
83 if ($e instanceof ilRpcClientException && $e->getCode() == 28) {
84 ilLoggerFactory::getLogger('src')->info('Connection timed out after ' . $this->timeout . ' seconds. ' .
85 'Indexing will continoue without a proper return message. View ilServer log if you think there are problems while indexing.');
86 $error_message = null;
87 }
88 }
89
91 if ($error_message) {
92 // #16035 - currently no way to discern the severity of the exception
93 $result->setMessage($error_message);
95 } else {
97 }
98 $result->setStatus($status);
99 return $result;
100 }
101
102
108 public static function updateLuceneIndex($a_obj_ids)
109 {
110 global $DIC;
111
112 $ilSetting = $DIC['ilSetting'];
113 include_once './Services/Search/classes/class.ilSearchSettings.php';
114 if (!ilSearchSettings::getInstance()->isLuceneUserSearchEnabled()) {
115 return false;
116 }
117
118 try {
119 ilLoggerFactory::getLogger('src')->info('Lucene update index call BEGIN --- ');
120
121 include_once './Services/WebServices/RPC/classes/class.ilRpcClientFactory.php';
122 ilRpcClientFactory::factory('RPCIndexHandler', 1)->indexObjects(
123 CLIENT_ID . '_' . $ilSetting->get('inst_id', 0),
124 $a_obj_ids
125 );
126 ilLoggerFactory::getLogger('src')->info('Lucene update index call --- END');
127 } catch (Exception $e) {
128 $error_message = $e->getMessage();
129 ilLoggerFactory::getLogger('src')->error($error_message);
130 return false;
131 }
132
133 return true;
134 }
135}
$result
An exception for terminatinating execution or to throw for unit testing.
Cron job result data container.
Cron job application base class.
const SCHEDULE_TYPE_DAILY
static getLogger($a_component_id)
Get component logger.
getDescription()
Get description.
getDefaultScheduleValue()
Get schedule value.
hasFlexibleSchedule()
Can the schedule be configured?
static updateLuceneIndex($a_obj_ids)
Update lucene index.
getDefaultScheduleType()
Get schedule type.
hasAutoActivation()
Is to be activated on "installation".
Class ilRpcClientException.
static factory($a_package, $a_timeout=0)
Creates an ilRpcClient instance to our ilServer.
const CLIENT_ID
Definition: constants.php:39
global $DIC
Definition: goto.php:24
global $ilSetting
Definition: privfeed.php:17
$lng