ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
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
array returns the input array
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...
 
- Public Member Functions inherited from ILIAS\BackgroundTasks\Task\Job
 run (array $input, Observer $observer)
 

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 ($values)
 
 extractType ($value)
 

Protected Attributes

ilSetting $settings
 
ilWorkspaceTree $tree
 
- Protected Attributes inherited from ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask
array $input = []
 
ILIAS BackgroundTasks 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 31 of file class.ilCheckSumOfWorkspaceFileSizesJob.php.

Constructor & Destructor Documentation

◆ __construct()

ilCheckSumOfWorkspaceFileSizesJob::__construct ( )

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

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

38  {
39  global $DIC;
40 
41  $user = $DIC->user();
42 
43  $this->logger = ilLoggerFactory::getLogger("pwsp");
44  $this->settings = new ilSetting("fold");
45  $this->tree = new ilWorkspaceTree($user->getId());
46  }
static getLogger(string $a_component_id)
Get component logger.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
+ 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 98 of file class.ilCheckSumOfWorkspaceFileSizesJob.php.

References $DIC, $type, ilObjFileAccess\_lookupFileSize(), ilObject\_lookupType(), ilTree\getChildsByTypeFilter(), ilWorkspaceTree\lookupObjectId(), and validateAccess().

Referenced by run().

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

145  : int
146  {
147  return 30;
148  }

◆ getInputTypes()

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

Implements ILIAS\BackgroundTasks\Task.

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

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

◆ getOutputType()

ilCheckSumOfWorkspaceFileSizesJob::getOutputType ( )

Implements ILIAS\BackgroundTasks\Task.

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

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

◆ 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 61 of file class.ilCheckSumOfWorkspaceFileSizesJob.php.

61  : bool
62  {
63  return true;
64  }

◆ run()

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

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

References calculateRecursive(), ILIAS\Repository\int(), ILIAS\Repository\logger(), and ILIAS\Repository\settings().

66  : Value
67  {
68  $this->logger->debug('Start checking adherence to maxsize!');
69  $this->logger->dump($input);
70  $definition = $input[0];
71  $object_wps_ids = $definition->getObjectWspIds();
72 
73  // get global limit (max sum of individual file-sizes) from file settings
74  $size_limit = (int) $this->settings->get("bgtask_download_limit", '0');
75  $size_limit_bytes = $size_limit * 1024 * 1024;
76  $this->logger->debug('Global limit (max sum of all file-sizes) in file-settings: ' . $size_limit_bytes . ' bytes');
77  // get sum of individual file-sizes
78  $total_bytes = 0;
79  $this->calculateRecursive($object_wps_ids, $total_bytes);
80  $this->logger->debug('Calculated sum of all file-sizes: ' . $total_bytes . 'MB');
81  // check if calculated total size adheres top global limit
82  $adheres_to_limit = new BooleanValue();
83  $adheres_to_limit->setValue(true);
84  if ($total_bytes > $size_limit_bytes) {
85  $adheres_to_limit->setValue(false);
86  }
87 
88  $definition->setSumFileSizes($total_bytes);
89  $definition->setAdheresToLimit($adheres_to_limit);
90 
91  return $definition;
92  }
calculateRecursive(array $object_wps_ids, int &$a_file_size)
Calculates the number and size of the files being downloaded recursively.
+ Here is the call graph for this function:

◆ validateAccess()

ilCheckSumOfWorkspaceFileSizesJob::validateAccess ( int  $wsp_id)
protected

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

Referenced by calculateRecursive().

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

Field Documentation

◆ $logger

ilLogger ilCheckSumOfWorkspaceFileSizesJob::$logger = null
private

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

◆ $settings

ilSetting ilCheckSumOfWorkspaceFileSizesJob::$settings
protected

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

◆ $tree

ilWorkspaceTree ilCheckSumOfWorkspaceFileSizesJob::$tree
protected

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


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