Skip to content

Commit

Permalink
EduGain hobs now can create a folder and delete dont call only on sof…
Browse files Browse the repository at this point in the history
…t delete
  • Loading branch information
temaotl committed Jul 15, 2024
1 parent 3aa5ac3 commit 50c6fd7
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
8 changes: 6 additions & 2 deletions app/Jobs/EduGainAddEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App\Facades\EntityFacade;
use App\Models\Entity;
use App\Traits\EdugainTrait;
use App\Traits\HandlesJobsFailuresTrait;
use Exception;
use Illuminate\Bus\Queueable;
Expand All @@ -18,7 +19,7 @@
class EduGainAddEntity implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
use HandlesJobsFailuresTrait;
use HandlesJobsFailuresTrait,EdugainTrait;

public Entity $entity;

Expand All @@ -37,6 +38,10 @@ public function handle(): void
{
$diskName = config('storageCfg.name');
$folderName = config('storageCfg.edu2edugain');
if (! Storage::disk($diskName)->exists($folderName)) {
$this->makeEdu2Edugain();
}

try {
if (! Storage::disk($diskName)->exists($folderName)) {
throw new Exception("No $folderName in $diskName");
Expand All @@ -51,7 +56,6 @@ public function handle(): void
$lock->block(61);
EntityFacade::saveEntityMetadataToFolder($this->entity->id, $folderName);

//TODO write custom function to run special MDA script (ask about this)
EduGainRunMdaScript::dispatch($lock->owner());

} catch (Exception $e) {
Expand Down
9 changes: 7 additions & 2 deletions app/Jobs/EduGainDeleteEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App\Facades\EntityFacade;
use App\Models\Entity;
use App\Traits\EdugainTrait;
use App\Traits\HandlesJobsFailuresTrait;
use Exception;
use Illuminate\Bus\Queueable;
Expand All @@ -22,7 +23,7 @@ class EduGainDeleteEntity implements ShouldQueue
/**
* trait with failure function
*/
use HandlesJobsFailuresTrait;
use HandlesJobsFailuresTrait,EdugainTrait;

public Entity $entity;

Expand All @@ -41,6 +42,11 @@ public function handle(): void
{
$diskName = config('storageCfg.name');
$folderName = config('storageCfg.edu2edugain');

if (! Storage::disk($diskName)->exists($folderName)) {
$this->makeEdu2Edugain();
}

try {
if (! Storage::disk($diskName)->exists($folderName)) {
throw new Exception("No $folderName in $diskName");
Expand All @@ -55,7 +61,6 @@ public function handle(): void
$lock->block(61);
EntityFacade::deleteEntityMetadataFromFolder($this->entity->file, $folderName);

//TODO write custom function to run special MDA script (ask about this)

EduGainRunMdaScript::dispatch($lock->owner());
} catch (Exception $e) {
Expand Down
12 changes: 9 additions & 3 deletions app/Listeners/SendDeletedEntityToDeleteJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,17 @@ public function __construct()
*/
public function handle(DeleteEntity $event): void
{
FolderDeleteEntity::dispatch($event->entity);
$entity = $event->entity;

if ($event->entity->edugain == 1) {
EduGainDeleteEntity::dispatch($event->entity);
if(!$entity->isForceDeleting())
{
FolderDeleteEntity::dispatch($event->entity);

if ($event->entity->edugain == 1) {
EduGainDeleteEntity::dispatch($event->entity);
}
}


}
}

0 comments on commit 50c6fd7

Please sign in to comment.