ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables Modules Pages
ilCalendarCopyFilesToTempDirectoryJob Class Reference

Description of class class. More...

+ Inheritance diagram for ilCalendarCopyFilesToTempDirectoryJob:
+ Collaboration diagram for ilCalendarCopyFilesToTempDirectoryJob:

Public Member Functions

 __construct ()
 Constructor. More...
 
 getInputTypes ()
 
 getOutputType ()
 
 isStateless ()
 
 run (array $input, Observer $observer)
 
 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
More...
 
- 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...
 

Protected Member Functions

 createUniqueTempDirectory ()
 
 createTargetDirectory (string $a_tmpdir)
 
 copyFiles (string $tmpdir, ilCalendarCopyDefinition $definition)
 Copy files. More...
 
- Protected Member Functions inherited from ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask
 checkTypes ($values)
 
 extractType ($value)
 

Protected Attributes

string $target_directory
 
- Protected Attributes inherited from ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask
array $input = []
 
ILIAS BackgroundTasks Value $output
 

Private Attributes

ilLogger $logger
 

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
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e

Definition at line 20 of file class.ilCalendarCopyFilesToTempDirectoryJob.php.

Constructor & Destructor Documentation

◆ __construct()

ilCalendarCopyFilesToTempDirectoryJob::__construct ( )

Constructor.

Definition at line 29 of file class.ilCalendarCopyFilesToTempDirectoryJob.php.

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

30  {
31  global $DIC;
32 
33  $this->logger = $DIC->logger()->cal();
34  }
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:

Member Function Documentation

◆ copyFiles()

ilCalendarCopyFilesToTempDirectoryJob::copyFiles ( string  $tmpdir,
ilCalendarCopyDefinition  $definition 
)
protected

Copy files.

Parameters
string$tmpdir
ilCalendarCopyDefinition$definition

Definition at line 120 of file class.ilCalendarCopyFilesToTempDirectoryJob.php.

References ilCalendarCopyDefinition\COPY_SOURCE_DIR, ilCalendarCopyDefinition\COPY_TARGET_DIR, ilCalendarCopyDefinition\getCopyDefinitions(), ILIAS\Repository\logger(), and ilFileUtils\makeDirParents().

Referenced by run().

120  : void
121  {
122  foreach ($definition->getCopyDefinitions() as $copy_task) {
123  if (!file_exists($copy_task[ilCalendarCopyDefinition::COPY_SOURCE_DIR])) {
124  $this->logger->notice('Cannot find file: ' . $copy_task[ilCalendarCopyDefinition::COPY_SOURCE_DIR]);
125  continue;
126  }
127  $this->logger->debug('Creating directory: ' . $tmpdir . '/' . dirname($copy_task[ilCalendarCopyDefinition::COPY_TARGET_DIR]));
129  $tmpdir . '/' . dirname($copy_task[ilCalendarCopyDefinition::COPY_TARGET_DIR])
130  );
131 
132  $this->logger->debug(
133  'Copying from: ' .
134  $copy_task[ilCalendarCopyDefinition::COPY_SOURCE_DIR] .
135  ' to ' .
136  $tmpdir . '/' . $copy_task[ilCalendarCopyDefinition::COPY_TARGET_DIR]
137  );
138 
139  copy(
140  $copy_task[ilCalendarCopyDefinition::COPY_SOURCE_DIR],
141  $tmpdir . '/' . $copy_task[ilCalendarCopyDefinition::COPY_TARGET_DIR]
142  );
143  }
144  }
getCopyDefinitions()
Get copy definitions.
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createTargetDirectory()

ilCalendarCopyFilesToTempDirectoryJob::createTargetDirectory ( string  $a_tmpdir)
protected

Definition at line 107 of file class.ilCalendarCopyFilesToTempDirectoryJob.php.

References $target_directory, ILIAS\Repository\logger(), and ilFileUtils\makeDirParents().

Referenced by run().

107  : string
108  {
109  $final_dir = $a_tmpdir . "/" . $this->target_directory;
110  ilFileUtils::makeDirParents($final_dir);
111  $this->logger->info('New final directory: ' . $final_dir);
112  return $final_dir;
113  }
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createUniqueTempDirectory()

ilCalendarCopyFilesToTempDirectoryJob::createUniqueTempDirectory ( )
protected
Returns
string absolute path to new temp directory
Todo:
refactor to new file system access Create unique temp directory

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

References ilFileUtils\ilTempnam(), ILIAS\Repository\logger(), and ilFileUtils\makeDirParents().

Referenced by run().

99  : string
100  {
101  $tmpdir = ilFileUtils::ilTempnam();
103  $this->logger->info('New temp directory: ' . $tmpdir);
104  return $tmpdir;
105  }
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
static ilTempnam(?string $a_temp_path=null)
Returns a unique and non existing Path for e temporary file or directory.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getExpectedTimeOfTaskInSeconds()

ilCalendarCopyFilesToTempDirectoryJob::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 149 of file class.ilCalendarCopyFilesToTempDirectoryJob.php.

149  : int
150  {
151  return 30;
152  }

◆ getInputTypes()

ilCalendarCopyFilesToTempDirectoryJob::getInputTypes ( )

Implements ILIAS\BackgroundTasks\Task.

Definition at line 39 of file class.ilCalendarCopyFilesToTempDirectoryJob.php.

39  : array
40  {
41  return
42  [
43  new SingleType(ilCalendarCopyDefinition::class)
44  ];
45  }

◆ getOutputType()

ilCalendarCopyFilesToTempDirectoryJob::getOutputType ( )

Todo:
output should be file type

Implements ILIAS\BackgroundTasks\Task.

Definition at line 51 of file class.ilCalendarCopyFilesToTempDirectoryJob.php.

51  : Type
52  {
53  return new SingleType(StringValue::class);
54  }

◆ isStateless()

ilCalendarCopyFilesToTempDirectoryJob::isStateless ( )

Implements ILIAS\BackgroundTasks\Task\Job.

Definition at line 59 of file class.ilCalendarCopyFilesToTempDirectoryJob.php.

59  : bool
60  {
61  return true;
62  }

◆ run()

ilCalendarCopyFilesToTempDirectoryJob::run ( array  $input,
Observer  $observer 
)

Implements ILIAS\BackgroundTasks\Task\Job.

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

References $out, copyFiles(), createTargetDirectory(), createUniqueTempDirectory(), and ILIAS\Repository\logger().

67  : Value
68  {
69  $cal_copy_def = $input[0];
70 
71  $this->logger->info('Called copy files job');
72 
73  $this->target_directory = $cal_copy_def->getTempDir();
74  //$this->target_directory = $input[1]->getValue();
75 
76  // create temp directory
77  $tmpdir = $this->createUniqueTempDirectory();
78  $targetdir = $this->createTargetDirectory($tmpdir);
79 
80  // copy files from source to temp directory
81  //$this->copyFiles($targetdir, $input[0]);
82  $this->copyFiles($targetdir, $cal_copy_def);
83 
84  // zip
85 
86  // return zip file name
87  $this->logger->debug('Returning new tempdirectory: ' . $targetdir);
88 
89  $out = new StringValue();
90  $out->setValue($targetdir);
91  return $out;
92  }
$out
Definition: buildRTE.php:24
copyFiles(string $tmpdir, ilCalendarCopyDefinition $definition)
Copy files.
+ Here is the call graph for this function:

Field Documentation

◆ $logger

ilLogger ilCalendarCopyFilesToTempDirectoryJob::$logger
private

◆ $target_directory

string ilCalendarCopyFilesToTempDirectoryJob::$target_directory
protected

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