ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilECSTaskScheduler Class Reference
+ Collaboration diagram for ilECSTaskScheduler:

Public Member Functions

 getServer ()
 Get server setting. More...
 
 startTaskExecution ()
 Start Tasks. More...
 

Static Public Member Functions

static _getInstanceByServerId ($a_server_id)
 get singleton instance Private access use ilECSTaskScheduler::start() or ilECSTaskScheduler::startTaskExecution More...
 

Data Fields

const MAX_TASKS = 30
 

Private Member Functions

 __construct (ilECSSetting $setting)
 Singleton constructor. More...
 
 readEvents ()
 Read EContent. More...
 
 handleEvents ()
 Handle events. More...
 
 handleDeprecatedAccounts ()
 Delete deprecate ECS accounts. More...
 
 readMIDs ()
 Read MID's of this installation. More...
 

Private Attributes

ilLogger $log
 
ilDBInterface $db
 
ilAppEventHandler $eventHandler
 
ilECSSetting $settings
 
ilECSEventQueueReader $event_reader = null
 
array $mids = array()
 

Static Private Attributes

static array $instances = array()
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilECSTaskScheduler::__construct ( ilECSSetting  $setting)
private

Singleton constructor.

Definition at line 43 of file class.ilECSTaskScheduler.php.

44 {
45 global $DIC;
46
47 $this->db = $DIC->database();
48 $this->log = $DIC->logger()->wsrv();
49 $this->eventHandler = $DIC->event();
50
51 $this->settings = $setting;
52 }
global $DIC
Definition: shib_login.php:26

References $DIC, and ILIAS\Repository\settings().

+ Here is the call graph for this function:

Member Function Documentation

◆ _getInstanceByServerId()

static ilECSTaskScheduler::_getInstanceByServerId (   $a_server_id)
static

get singleton instance Private access use ilECSTaskScheduler::start() or ilECSTaskScheduler::startTaskExecution

Definition at line 60 of file class.ilECSTaskScheduler.php.

61 {
62 return self::$instances[$a_server_id] ?? (self::$instances[$a_server_id] =
65 ));
66 }
static getInstanceByServerId(int $a_server_id)
Get singleton instance per server.

References ilECSSetting\getInstanceByServerId().

Referenced by ilECSSettingsGUI\readAll(), and ilCronEcsTaskScheduler\run().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getServer()

ilECSTaskScheduler::getServer ( )

Get server setting.

Returns
ilECSSetting

Definition at line 72 of file class.ilECSTaskScheduler.php.

References $settings.

Referenced by handleEvents(), readEvents(), and readMIDs().

+ Here is the caller graph for this function:

◆ handleDeprecatedAccounts()

ilECSTaskScheduler::handleDeprecatedAccounts ( )
private

Delete deprecate ECS accounts.

Definition at line 219 of file class.ilECSTaskScheduler.php.

219 : void
220 {
221 $query = "SELECT usr_id FROM usr_data WHERE auth_mode = 'ecs' " .
222 "AND time_limit_until < " . time() . " " .
223 "AND time_limit_unlimited = 0 " .
224 "AND (time_limit_until - time_limit_from) < 7200";
225 $res = $this->db->query($query);
226 if (($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) &&
227 $user_obj = ilObjectFactory::getInstanceByObjId((int) $row->usr_id, false)) {
228 $this->log->info(__METHOD__ . ': Deleting deprecated ECS user account ' . $user_obj->getLogin());
229 $user_obj->delete();
230 }
231 }
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
$res
Definition: ltiservices.php:69

References $res, ilDBConstants\FETCHMODE_OBJECT, and ilObjectFactory\getInstanceByObjId().

Referenced by startTaskExecution().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ handleEvents()

ilECSTaskScheduler::handleEvents ( )
private

Handle events.

Definition at line 108 of file class.ilECSTaskScheduler.php.

108 : void
109 {
110 for ($i = 0;$i < self::MAX_TASKS;$i++) {
111 if (!$event = $this->event_reader->shift()) {
112 $this->log->info(__METHOD__ . ': No more pending events found. DONE');
113 break;
114 }
115
116 $this->log->info("Eventdump" . print_r($event, true));
117
118 // determine event handler
119
120 $event_ignored = false;
121 switch ($event['type']) {
131 if ($handler) {
132 $this->log->debug("got handler " . get_class($handler));
133 } else {
134 $this->log->error("Could not get handler for :" . $event['type']);
135 }
136 break;
137
139 $this->log->debug('Handling new cms tree event.');
141 break;
142
145 break;
146
149 break;
150
152 $this->log->info(__METHOD__ . ': Ignoring event type in queue ' . $event['type']);
153 $event_ignored = true;
154 break;
155
158 break;
159
160 default:
161
162 $this->log->warning('Unknown type in queue, raising new event handling event: ' . $event['type']);
163 $event_ignored = true;
164
165 $this->eventHandler->raise(
166 'components/ILIAS/WebServices/ECS',
167 'newEcsEvent',
168 array('event' => $event)
169 );
170 break;
171 }
172
173 if ($event_ignored) {
174 $this->event_reader->deleteEvent($event['event_id']);
175 continue;
176 }
177
178 $res = false;
179 if (isset($handler)) {
180 switch ($event['op']) {
182 // DEPRECATED?
183 // $this->handleNewlyCreate($event['id']);
184 // $this->log->write(__METHOD__.': Handling new creation. DONE');
185 break;
186
188 $res = $handler->handleDelete($this->getServer(), $event['id'], $this->mids);
189 $this->log->info(__METHOD__ . ': Handling delete. DONE');
190 break;
191
193 $res = $handler->handleCreate($this->getServer(), $event['id'], $this->mids);
194 $this->log->info(__METHOD__ . ': Handling create. DONE');
195 break;
196
198 $res = $handler->handleUpdate($this->getServer(), $event['id'], $this->mids);
199 $this->log->info(__METHOD__ . ': Handling update. DONE');
200 break;
201
202 default:
203 $this->log->info(__METHOD__ . ': Unknown event operation in queue ' . $event['op']);
204 break;
205 }
206 }
207 if ($res) {
208 $this->log->info(__METHOD__ . ': Processing of event done ' . $event['event_id']);
209 $this->event_reader->deleteEvent($event['event_id']);
210 } else {
211 $this->log->info(__METHOD__ . ': Processing of event failed ' . $event['event_id']);
212 }
213 }
214 }
getServer()
Get server setting.
static getInstanceByEventType(string $a_type)
Get instance by ilECSEvent(QueueReader) type.
$handler
Definition: oai.php:29

References $handler, $res, ilECSEvent\CREATED, ilECSEvent\DESTROYED, ilRemoteObjectBase\getInstanceByEventType(), getServer(), MAX_TASKS, ilECSEvent\NEW_EXPORT, ilECSEventQueueReader\TYPE_CMS_COURSE_MEMBERS, ilECSEventQueueReader\TYPE_CMS_COURSES, ilECSEventQueueReader\TYPE_COURSE_URLS, ilECSEventQueueReader\TYPE_DIRECTORY_TREES, ilECSEventQueueReader\TYPE_ENROLMENT_STATUS, ilECSEventQueueReader\TYPE_REMOTE_CATEGORY, ilECSEventQueueReader\TYPE_REMOTE_COURSE, ilECSEventQueueReader\TYPE_REMOTE_FILE, ilECSEventQueueReader\TYPE_REMOTE_GLOSSARY, ilECSEventQueueReader\TYPE_REMOTE_GROUP, ilECSEventQueueReader\TYPE_REMOTE_LEARNING_MODULE, ilECSEventQueueReader\TYPE_REMOTE_TEST, ilECSEventQueueReader\TYPE_REMOTE_WIKI, and ilECSEvent\UPDATED.

Referenced by startTaskExecution().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readEvents()

ilECSTaskScheduler::readEvents ( )
private

Read EContent.

Definition at line 99 of file class.ilECSTaskScheduler.php.

99 : void
100 {
101 $this->event_reader = new ilECSEventQueueReader($this->getServer());
102 $this->event_reader->refresh();
103 }
Reads ECS events and stores them in the database.

References getServer().

Referenced by startTaskExecution().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readMIDs()

ilECSTaskScheduler::readMIDs ( )
private

Read MID's of this installation.

Definition at line 236 of file class.ilECSTaskScheduler.php.

236 : void
237 {
238 $this->mids = array();
239
240 $reader = ilECSCommunityReader::getInstanceByServerId($this->getServer()->getServerId());
241 foreach ($reader->getCommunities() as $com) {
242 foreach ($com->getParticipants() as $part) {
243 if ($part->isSelf()) {
244 $this->mids[] = $part->getMID();
245 }
246 }
247 }
248 }
static getInstanceByServerId(int $a_server_id)
Get instance by server id.

References ilECSCommunityReader\getInstanceByServerId(), and getServer().

Referenced by startTaskExecution().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ startTaskExecution()

ilECSTaskScheduler::startTaskExecution ( )

Start Tasks.

Definition at line 81 of file class.ilECSTaskScheduler.php.

81 : bool
82 {
83 try {
84 $this->readMIDs();
85 $this->readEvents();
86 $this->handleEvents();
87
89 } catch (ilException $exc) {
90 $this->log->warning('Cannot start ecs task execution: ' . $exc->getMessage());
91 return false;
92 }
93 return true;
94 }
handleDeprecatedAccounts()
Delete deprecate ECS accounts.
readMIDs()
Read MID's of this installation.
Base class for ILIAS Exception handling.

References handleDeprecatedAccounts(), handleEvents(), readEvents(), and readMIDs().

+ Here is the call graph for this function:

Field Documentation

◆ $db

ilDBInterface ilECSTaskScheduler::$db
private

Definition at line 32 of file class.ilECSTaskScheduler.php.

◆ $event_reader

ilECSEventQueueReader ilECSTaskScheduler::$event_reader = null
private

Definition at line 37 of file class.ilECSTaskScheduler.php.

◆ $eventHandler

ilAppEventHandler ilECSTaskScheduler::$eventHandler
private

Definition at line 33 of file class.ilECSTaskScheduler.php.

◆ $instances

array ilECSTaskScheduler::$instances = array()
staticprivate

Definition at line 28 of file class.ilECSTaskScheduler.php.

◆ $log

ilLogger ilECSTaskScheduler::$log
private

Definition at line 31 of file class.ilECSTaskScheduler.php.

◆ $mids

array ilECSTaskScheduler::$mids = array()
private

Definition at line 38 of file class.ilECSTaskScheduler.php.

◆ $settings

ilECSSetting ilECSTaskScheduler::$settings
private

Definition at line 36 of file class.ilECSTaskScheduler.php.

Referenced by getServer().

◆ MAX_TASKS

const ilECSTaskScheduler::MAX_TASKS = 30

Definition at line 26 of file class.ilECSTaskScheduler.php.

Referenced by handleEvents().


The documentation for this class was generated from the following file: