ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilCheckSumOfWorkspaceFileSizesJob Class Reference

Description of class class. More...

+ Inheritance diagram for ilCheckSumOfWorkspaceFileSizesJob:
+ Collaboration diagram for ilCheckSumOfWorkspaceFileSizesJob:

Public Member Functions

 __construct ()
 
 getInputTypes ()
 
 getOutputType ()
 
 isStateless ()
 
 run (array $input, \ILIAS\BackgroundTasks\Observer $observer)
 
 getExpectedTimeOfTaskInSeconds ()
 
- Public Member Functions inherited from ILIAS\BackgroundTasks\Implementation\Tasks\AbstractJob
 getInput ()
 
Returns
Value[]
More...
 
- Public Member Functions inherited from ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask
 setInput (array $values)
 
 getOutput ()
 
 getInput ()
 
 getType ()
 
 unfoldTask ()
 Unfold the task. More...
 
 getRemoveOption ()
 
Returns
Option An Option to remove the current task and do some cleanup if possible. This Option is displayed if the Bucket is completed. You do not have to provide an additional Option to remove in your UserInteraction, the remove-Option is added to the list of Options (last position)
See also
self::getAbortOption();
More...
 
 getAbortOption ()
 
Returns
Option In case a Job is failed or did not respond for some time, an Abort-Option is displayed. There is already a Standard-Abort-Option registered, you can override with your own and do some cleanup if possible.
More...
 
 getType ()
 
 getInputTypes ()
 
 getOutputType ()
 
 getOutput ()
 
 setInput (array $values)
 
 getInput ()
 
 unfoldTask ()
 
 getRemoveOption ()
 
 getAbortOption ()
 
- Public Member Functions inherited from ILIAS\BackgroundTasks\Task\Job
 run (array $input, Observer $observer)
 
 isStateless ()
 
 getInput ()
 
 getExpectedTimeOfTaskInSeconds ()
 

Protected Member Functions

 calculateRecursive (array $object_wps_ids, int &$a_file_size)
 Calculates the number and size of the files being downloaded recursively. More...
 
 validateAccess (int $wsp_id)
 
- Protected Member Functions inherited from ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask
 checkTypes (array $values)
 
 extractType ($value)
 

Protected Attributes

ilSetting $settings
 
ilWorkspaceTree $tree
 
- Protected Attributes inherited from ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask
array $input = []
 
Value $output
 

Private Attributes

ilLogger $logger = null
 

Additional Inherited Members

- Data Fields inherited from ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask
const MAIN_REMOVE = 'bt_main_remove'
 
const MAIN_ABORT = 'bt_main_abort'
 

Detailed Description

Description of class class.

Author
killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

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

Constructor & Destructor Documentation

◆ __construct()

ilCheckSumOfWorkspaceFileSizesJob::__construct ( )

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

39 {
40 global $DIC;
41
42 $user = $DIC->user();
43
44 $this->logger = ilLoggerFactory::getLogger("pwsp");
45 $this->settings = new ilSetting("fold");
46 $this->tree = new ilWorkspaceTree($user->getId());
47 }
static getLogger(string $a_component_id)
Get component logger.
ILIAS Setting Class.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: shib_login.php:26

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

+ Here is the call graph for this function:

Member Function Documentation

◆ calculateRecursive()

ilCheckSumOfWorkspaceFileSizesJob::calculateRecursive ( array  $object_wps_ids,
int &  $a_file_size 
)
protected

Calculates the number and size of the files being downloaded recursively.

Definition at line 100 of file class.ilCheckSumOfWorkspaceFileSizesJob.php.

103 : void {
104 global $DIC;
105 $tree = $DIC['tree'];
106
107 // parse folders
108 foreach ($object_wps_ids as $object_wps_id) {
109 if (!$this->validateAccess($object_wps_id)) {
110 continue;
111 }
112
113 // we are only interested in folders and files
114 $obj_id = $this->tree->lookupObjectId($object_wps_id);
115 $type = ilObject::_lookupType($obj_id);
116 switch ($type) {
117 case "wfld":
118 // get child objects
119 $subtree = $tree->getChildsByTypeFilter($object_wps_id, array("wfld", "file"));
120 if (count($subtree) > 0) {
121 $child_wsp_ids = array();
122 foreach ($subtree as $child) {
123 $child_wsp_ids[] = $child["child"];
124 }
125 $this->calculateRecursive($child_wsp_ids, $a_file_size);
126 }
127 break;
128
129 case "file":
130 $a_file_size += ilObjFileAccess::_lookupFileSize($obj_id, false);
131 break;
132 }
133 }
134 }
calculateRecursive(array $object_wps_ids, int &$a_file_size)
Calculates the number and size of the files being downloaded recursively.
static _lookupFileSize(int $a_id, bool $by_reference=true)
static _lookupType(int $id, bool $reference=false)
getChildsByTypeFilter(int $a_node_id, array $a_types, string $a_order="", string $a_direction="ASC")
get child nodes of given node by object type

References $tree, ilObjFileAccess\_lookupFileSize(), ilObject\_lookupType(), calculateRecursive(), ilTree\getChildsByTypeFilter(), and validateAccess().

Referenced by calculateRecursive(), and run().

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

◆ getExpectedTimeOfTaskInSeconds()

ilCheckSumOfWorkspaceFileSizesJob::getExpectedTimeOfTaskInSeconds ( )
Returns
int the amount of seconds this task usually taskes. If your task-duration scales with the the amount of data, try to set a possible high value of try to calculate it. If a task duration exceeds this value, it will be displayed as "possibly failed" to the user

Implements ILIAS\BackgroundTasks\Task\Job.

Definition at line 147 of file class.ilCheckSumOfWorkspaceFileSizesJob.php.

147 : int
148 {
149 return 30;
150 }

◆ getInputTypes()

ilCheckSumOfWorkspaceFileSizesJob::getInputTypes ( )
Returns
Type[] A list of types that are taken as input.

Implements ILIAS\BackgroundTasks\Task.

Definition at line 49 of file class.ilCheckSumOfWorkspaceFileSizesJob.php.

49 : array
50 {
51 return
52 [
53 new SingleType(ilWorkspaceCopyDefinition::class),
54 ];
55 }

◆ getOutputType()

ilCheckSumOfWorkspaceFileSizesJob::getOutputType ( )

Implements ILIAS\BackgroundTasks\Task.

Definition at line 57 of file class.ilCheckSumOfWorkspaceFileSizesJob.php.

57 : Type
58 {
59 return new SingleType(ilWorkspaceCopyDefinition::class);
60 }

◆ isStateless()

ilCheckSumOfWorkspaceFileSizesJob::isStateless ( )
Returns
bool returns true iff the job's output ONLY depends on the input. Stateless task results may be cached!

Implements ILIAS\BackgroundTasks\Task\Job.

Definition at line 62 of file class.ilCheckSumOfWorkspaceFileSizesJob.php.

62 : bool
63 {
64 return true;
65 }

◆ run()

ilCheckSumOfWorkspaceFileSizesJob::run ( array  $input,
\ILIAS\BackgroundTasks\Observer  $observer 
)

Definition at line 67 of file class.ilCheckSumOfWorkspaceFileSizesJob.php.

67 : Value
68 {
69 $this->logger->debug('Start checking adherence to maxsize!');
70 $this->logger->dump($input);
71 $definition = $input[0];
72 $object_wps_ids = $definition->getObjectWspIds();
73
74 // get global limit (max sum of individual file-sizes) from file settings
75 $general = new General();
76 $size_limit = $general->getDownloadLimitinMB();
77 $size_limit_bytes = $size_limit * 1024 * 1024;
78 $this->logger->debug('Global limit (max sum of all file-sizes) in file-settings: ' . $size_limit_bytes . ' bytes');
79 // get sum of individual file-sizes
80 $total_bytes = 0;
81 $this->calculateRecursive($object_wps_ids, $total_bytes);
82 $this->logger->debug('Calculated sum of all file-sizes: ' . $total_bytes . ' B');
83 // check if calculated total size adheres top global limit
84 $adheres_to_limit = new BooleanValue();
85 $adheres_to_limit->setValue(true);
86 if ($total_bytes > $size_limit_bytes) {
87 $adheres_to_limit->setValue(false);
88 }
89
90 $definition->setSumFileSizes($total_bytes);
91 $definition->setAdheresToLimit($adheres_to_limit);
92
93 return $definition;
94 }
$general
SECTIONS.

References $general, ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask\$input, calculateRecursive(), and ILIAS\Repository\logger().

+ Here is the call graph for this function:

◆ validateAccess()

ilCheckSumOfWorkspaceFileSizesJob::validateAccess ( int  $wsp_id)
protected

Definition at line 136 of file class.ilCheckSumOfWorkspaceFileSizesJob.php.

136 : bool
137 {
138 $ilAccess = new ilWorkspaceAccessHandler($this->tree);
139
140 if (!$ilAccess->checkAccess("read", "", $wsp_id)) {
141 return false;
142 }
143
144 return true;
145 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

Referenced by calculateRecursive().

+ Here is the caller graph for this function:

Field Documentation

◆ $logger

ilLogger ilCheckSumOfWorkspaceFileSizesJob::$logger = null
private

Definition at line 34 of file class.ilCheckSumOfWorkspaceFileSizesJob.php.

◆ $settings

ilSetting ilCheckSumOfWorkspaceFileSizesJob::$settings
protected

Definition at line 35 of file class.ilCheckSumOfWorkspaceFileSizesJob.php.

◆ $tree

ilWorkspaceTree ilCheckSumOfWorkspaceFileSizesJob::$tree
protected

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

Referenced by calculateRecursive().


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