ILIAS  trunk Revision v11.0_alpha-1753-gb21ca8c4367
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilDownloadWorkspaceFolderBackgroundTask Class Reference

Background task for downloads. More...

+ Collaboration diagram for ilDownloadWorkspaceFolderBackgroundTask:

Public Member Functions

 __construct (int $a_usr_id, array $a_object_wsp_ids, bool $a_initiated_by_folder_action=false)
 
 setBucketTitle (string $a_title)
 
 getBucketTitle ()
 
 run ()
 

Protected Attributes

ilLanguage $lng
 
int $user_id
 
array $object_wsp_ids
 
bool $initiated_by_folder_action = false
 determines whether the task has been initiated by a folder's action drop-down to prevent a folder duplicate inside the zip. More...
 
ILIAS BackgroundTasks Task TaskFactory $task_factory = null
 
string $bucket_title
 
bool $has_files = false
 

Private Attributes

ilLogger $logger = null
 

Detailed Description

Background task for downloads.

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

Definition at line 27 of file class.ilDownloadWorkspaceFolderBackgroundTask.php.

Constructor & Destructor Documentation

◆ __construct()

ilDownloadWorkspaceFolderBackgroundTask::__construct ( int  $a_usr_id,
array  $a_object_wsp_ids,
bool  $a_initiated_by_folder_action = false 
)

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

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

47  {
48  global $DIC;
49  $this->logger = ilLoggerFactory::getLogger("pwsp");
50  $this->user_id = $a_usr_id;
51  $this->object_wsp_ids = $a_object_wsp_ids;
52  $this->initiated_by_folder_action = $a_initiated_by_folder_action;
53  $this->task_factory = $DIC->backgroundTasks()->taskFactory();
54  $this->lng = $DIC->language();
55  }
static getLogger(string $a_component_id)
Get component logger.
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:

Member Function Documentation

◆ getBucketTitle()

ilDownloadWorkspaceFolderBackgroundTask::getBucketTitle ( )

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

References $bucket_title.

Referenced by run().

62  : string
63  {
64  //TODO: fix ilUtil zip stuff
65  // Error If name starts "-"
66  // error massage from ilUtil->execQuoted = ["","zip error: Invalid command arguments (short option 'a' not supported)"]
67  if (substr($this->bucket_title, 0, 1) === "-") {
68  $this->bucket_title = ltrim($this->bucket_title, "-");
69  }
70 
71  return $this->bucket_title;
72  }
+ Here is the caller graph for this function:

◆ run()

ilDownloadWorkspaceFolderBackgroundTask::run ( )

Definition at line 74 of file class.ilDownloadWorkspaceFolderBackgroundTask.php.

References $GLOBALS, ilFileUtils\getASCIIFilename(), getBucketTitle(), and ILIAS\Repository\logger().

74  : bool
75  {
76  // This is our Bucket
77  $this->logger->info('Started download workspace files background task');
78  $normalized_name = ilFileUtils::getASCIIFilename($this->getBucketTitle());
79  $bucket = new BasicBucket();
80  $bucket->setUserId($this->user_id);
81  $bucket->setTitle($normalized_name);
82  $this->logger->debug('Created bucket and set the following user id: ' . $this->user_id);
83 
84  // Copy Definition
85  $definition = new ilWorkspaceCopyDefinition();
86  $definition->setTempDir($normalized_name);
87  $definition->setObjectWspIds($this->object_wsp_ids);
88  $this->logger->debug('Created copy definition and added the following tempdir: ' . $normalized_name);
89 
90  // Collect all files by the definition and prevent duplicates
91  $collect_job = $this->task_factory->createTask(ilCollectWorkspaceFilesJob::class, [$definition, $this->initiated_by_folder_action]);
92  $this->logger->debug('Collected files based on the following object ids: ');
93  $this->logger->dump($this->object_wsp_ids);
94 
95  // Check the FileSize
96  $file_size_job = $this->task_factory->createTask(ilCheckSumOfWorkspaceFileSizesJob::class, [$collect_job]);
97 
98  // Show problems with file-limit
99  $file_size_interaction = $this->task_factory->createTask(ilSumOfWorkspaceFileSizesTooLargeInteraction::class, [$file_size_job]);
100  $this->logger->debug('Determined the sum of all file sizes');
101 
102  // move files from source dir to target directory
103  $copy_job = $this->task_factory->createTask(ilCopyWorkspaceFilesToTempDirectoryJob::class, [$file_size_interaction]);
104 
105  // Zip it
106  $zip_job = $this->task_factory->createTask(ilZipJob::class, [$copy_job]);
107  $this->logger->debug('Moved files from source- to target-directory');
108 
109  // Download
110  $download_name = new StringValue();
111  $download_name->setValue($normalized_name . '.zip');
112  $download_interaction = $this->task_factory->createTask(ilDownloadZipInteraction::class, [$zip_job, $download_name]);
113  $this->logger->debug('Created a download interaction with the following download name: ' . $download_name->getValue());
114 
115  // last task to bucket
116  $bucket->setTask($download_interaction);
117  $bucket->setTitle($this->getBucketTitle());
118  $this->logger->debug('Added last task to bucket and set the following title: ' . $this->getBucketTitle());
119 
120  $task_manager = $GLOBALS['DIC']->backgroundTasks()->taskManager();
121  $task_manager->run($bucket);
122  $this->logger->debug('Ran bucket in task manager');
123 
124  return true;
125  }
static getASCIIFilename(string $a_filename)
$GLOBALS["DIC"]
Definition: wac.php:53
Copy definition for workspace folders.
+ Here is the call graph for this function:

◆ setBucketTitle()

ilDownloadWorkspaceFolderBackgroundTask::setBucketTitle ( string  $a_title)

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

57  : void
58  {
59  $this->bucket_title = $a_title;
60  }

Field Documentation

◆ $bucket_title

string ilDownloadWorkspaceFolderBackgroundTask::$bucket_title
protected

Definition at line 40 of file class.ilDownloadWorkspaceFolderBackgroundTask.php.

Referenced by getBucketTitle().

◆ $has_files

bool ilDownloadWorkspaceFolderBackgroundTask::$has_files = false
protected

◆ $initiated_by_folder_action

bool ilDownloadWorkspaceFolderBackgroundTask::$initiated_by_folder_action = false
protected

determines whether the task has been initiated by a folder's action drop-down to prevent a folder duplicate inside the zip.

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

◆ $lng

ilLanguage ilDownloadWorkspaceFolderBackgroundTask::$lng
protected

◆ $logger

ilLogger ilDownloadWorkspaceFolderBackgroundTask::$logger = null
private

◆ $object_wsp_ids

array ilDownloadWorkspaceFolderBackgroundTask::$object_wsp_ids
protected

◆ $task_factory

ILIAS BackgroundTasks Task TaskFactory ilDownloadWorkspaceFolderBackgroundTask::$task_factory = null
protected

◆ $user_id

int ilDownloadWorkspaceFolderBackgroundTask::$user_id
protected

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