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

Description of class class. More...

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

Public Member Functions

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

Protected Member Functions

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

Protected Attributes

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

Private Attributes

ilLogger $logger
 
ILIAS ResourceStorage Services $irss
 

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

Constructor & Destructor Documentation

◆ __construct()

ilCalendarCopyFilesToTempDirectoryJob::__construct ( )

Constructor.

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

45 {
46 global $DIC;
47
48 $this->irss = $DIC->resourceStorage();
49 $this->logger = $DIC->logger()->cal();
50 }
global $DIC
Definition: shib_login.php:26

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

+ Here is the call graph for this function:

Member Function Documentation

◆ copyFiles()

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

Copy files.

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

134 : void
135 {
136 foreach ($definition->getCopyDefinitions() as $copy_task) {
138 $this->copyWithRId($tmpdir, $copy_task);
139 } else {
140 $this->copyWithAbsolutePath($tmpdir, $copy_task);
141 }
142 }
143 }

References ilCalendarRessourceStorageCopyDefinition\COPY_RESSOURCE_ID, copyWithAbsolutePath(), copyWithRId(), and ilCalendarRessourceStorageCopyDefinition\getCopyDefinitions().

Referenced by run().

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

◆ copyWithAbsolutePath()

ilCalendarCopyFilesToTempDirectoryJob::copyWithAbsolutePath ( string  $tmpdir,
array  $copy_task 
)
protected

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

167 {
170
171 if (!file_exists($absolute_path)) {
172 $this->logger->notice('Cannot find file: ' . $absolute_path);
173 return;
174 }
175
176 $this->logger->debug('Creating directory: ' . $tmpdir . '/' . dirname($target_dir));
177 ilFileUtils::makeDirParents($tmpdir . '/' . dirname($target_dir));
178 $this->logger->debug('Copying from: ' . $absolute_path . ' to ' . $tmpdir . '/' . $target_dir);
179
180 copy($absolute_path, $tmpdir . '/' . $target_dir);
181 }
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.

References ilCalendarRessourceStorageCopyDefinition\COPY_ABSOLUTE_PATH, ilCalendarRessourceStorageCopyDefinition\COPY_TARGET_DIR, ILIAS\Repository\logger(), and ilFileUtils\makeDirParents().

Referenced by copyFiles().

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

◆ copyWithRId()

ilCalendarCopyFilesToTempDirectoryJob::copyWithRId ( string  $tmpdir,
array  $copy_task 
)
protected

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

146 {
149 $resource_identification = $this->irss->manage()->find($rid);
150
151 if(is_null($resource_identification)) {
152 $this->logger->notice('Cannot ressource identification of rid: ' . $rid);
153 return;
154 }
155
156 $this->logger->debug('Creating directory: ' . $tmpdir . '/' . dirname($target_dir));
157 ilFileUtils::makeDirParents($tmpdir . '/' . dirname($target_dir));
158 $this->logger->debug('Copying ressource with id: ' . $rid . ' to ' . $tmpdir . '/' . $target_dir);
159
160 file_put_contents(
162 $this->irss->consume()->stream($resource_identification)->getStream()
163 );
164 }

References ilCalendarRessourceStorageCopyDefinition\COPY_RESSOURCE_ID, ilCalendarRessourceStorageCopyDefinition\COPY_TARGET_DIR, ILIAS\Repository\logger(), and ilFileUtils\makeDirParents().

Referenced by copyFiles().

+ 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 123 of file class.ilCalendarCopyFilesToTempDirectoryJob.php.

123 : string
124 {
125 $final_dir = $a_tmpdir . "/" . $this->target_directory;
126 ilFileUtils::makeDirParents($final_dir);
127 $this->logger->info('New final directory: ' . $final_dir);
128 return $final_dir;
129 }

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

Referenced by run().

+ 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 115 of file class.ilCalendarCopyFilesToTempDirectoryJob.php.

115 : string
116 {
117 $tmpdir = ilFileUtils::ilTempnam();
119 $this->logger->info('New temp directory: ' . $tmpdir);
120 return $tmpdir;
121 }
static ilTempnam(?string $a_temp_path=null)
Returns a unique and non existing Path for e temporary file or directory.

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

Referenced by run().

+ 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 186 of file class.ilCalendarCopyFilesToTempDirectoryJob.php.

186 : int
187 {
188 return 30;
189 }

◆ getInputTypes()

ilCalendarCopyFilesToTempDirectoryJob::getInputTypes ( )

@inheritDoc

Implements ILIAS\BackgroundTasks\Task.

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

55 : array
56 {
57 return
58 [
59 new SingleType(ilCalendarRessourceStorageCopyDefinition::class)
60 ];
61 }

◆ getOutputType()

ilCalendarCopyFilesToTempDirectoryJob::getOutputType ( )

@inheritDoc

Todo:
output should be file type

Implements ILIAS\BackgroundTasks\Task.

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

67 : Type
68 {
69 return new SingleType(StringValue::class);
70 }

◆ isStateless()

ilCalendarCopyFilesToTempDirectoryJob::isStateless ( )

@inheritDoc

Implements ILIAS\BackgroundTasks\Task\Job.

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

75 : bool
76 {
77 return true;
78 }

◆ run()

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

@inheritDoc

Implements ILIAS\BackgroundTasks\Task\Job.

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

83 : Value
84 {
85 $cal_copy_def = $input[0];
86
87 $this->logger->info('Called copy files job');
88
89 $this->target_directory = $cal_copy_def->getTempDir();
90 //$this->target_directory = $input[1]->getValue();
91
92 // create temp directory
93 $tmpdir = $this->createUniqueTempDirectory();
94 $targetdir = $this->createTargetDirectory($tmpdir);
95
96 // copy files from source to temp directory
97 //$this->copyFiles($targetdir, $input[0]);
98 $this->copyFiles($targetdir, $cal_copy_def);
99
100 // zip
101
102 // return zip file name
103 $this->logger->debug('Returning new tempdirectory: ' . $targetdir);
104
105 $out = new StringValue();
106 $out->setValue($targetdir);
107 return $out;
108 }
$out
Definition: buildRTE.php:24
copyFiles(string $tmpdir, ilCalendarRessourceStorageCopyDefinition $definition)
Copy files.

References ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask\$input, $out, copyFiles(), createTargetDirectory(), createUniqueTempDirectory(), and ILIAS\Repository\logger().

+ Here is the call graph for this function:

Field Documentation

◆ $irss

ILIAS ResourceStorage Services ilCalendarCopyFilesToTempDirectoryJob::$irss
private

◆ $logger

ilLogger ilCalendarCopyFilesToTempDirectoryJob::$logger
private

◆ $target_directory

string ilCalendarCopyFilesToTempDirectoryJob::$target_directory
protected

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