Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Entity feature #27

Merged
merged 53 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
95c9ca6
add xml_file field to update case in store
temaotl Jul 2, 2024
c8a44b7
fix test and commit Bus:chain
temaotl Jul 2, 2024
f1d9d75
start with job
temaotl Jul 3, 2024
004d099
rewrite update to transaction
temaotl Jul 3, 2024
9eb036f
use pint for code style
temaotl Jul 3, 2024
3043cb7
make save job
temaotl Jul 3, 2024
61553ca
make update (no tested)
temaotl Jul 3, 2024
fa6a79e
rewrite metadata storage name to config file
temaotl Jul 8, 2024
753bfed
change saving attribute from name to xml_id
temaotl Jul 8, 2024
aaaf675
make Cache lock on job
temaotl Jul 8, 2024
78a2bd6
make run script function
temaotl Jul 9, 2024
25e4537
rewrite to Locks Across Processes
temaotl Jul 9, 2024
7e409d8
mke mda paths with env
temaotl Jul 9, 2024
ba44a89
make RateLimited for RunMdaScript job
temaotl Jul 9, 2024
39e13ef
fix dump from git
temaotl Jul 9, 2024
dcfba68
only approved entity can start a job
temaotl Jul 10, 2024
ec08f0b
fix lock and use pint
temaotl Jul 10, 2024
87e1462
make delete but without job
temaotl Jul 10, 2024
073ece6
turn off most old git jobs
temaotl Jul 10, 2024
dc72ba0
make delete with job and make Failure part of job
temaotl Jul 11, 2024
6d8b4b3
fix test now it's working with delete job
temaotl Jul 11, 2024
87250fe
make restore with job
temaotl Jul 11, 2024
7eac6ef
make new NotificationService (not tested)
temaotl Jul 12, 2024
eb4e015
make new NotificationService (not tested)
temaotl Jul 12, 2024
d099eb7
uncommented notification and make better RunMdaScript
temaotl Jul 13, 2024
0094a51
rewrite edu2edugain to config
temaotl Jul 13, 2024
9e99685
start write new job for EduGain (not ready script run part)
temaotl Jul 13, 2024
e612537
write working EduToEdugain jobs but without mda script
temaotl Jul 13, 2024
1a79a55
add run script to EduGain jobs
temaotl Jul 13, 2024
dd1446f
run pint
temaotl Jul 13, 2024
7d13e99
fix tests
temaotl Jul 15, 2024
3aa5ac3
fix test and run pint
temaotl Jul 15, 2024
50c6fd7
EduGain hobs now can create a folder and delete dont call only on sof…
temaotl Jul 15, 2024
c3fbdc7
fix test and run pint
temaotl Jul 16, 2024
7c08067
notifications (without Membership accepted )
temaotl Jul 16, 2024
ff6062a
make better seeder run pint and fix FolderAddEntity
temaotl Jul 17, 2024
d0a1cff
make event to work with membership table
temaotl Jul 17, 2024
89f8ca6
add new save membership job
temaotl Jul 18, 2024
cb3d302
add delete from federation
temaotl Jul 19, 2024
32e3d30
fix notification
temaotl Jul 19, 2024
359483c
fix fail part
temaotl Jul 19, 2024
aa68ba6
rewrite event to observer
temaotl Jul 22, 2024
8ef930e
fix bug with second update
temaotl Jul 22, 2024
4069f7c
make NotificationService.php more abstract and add notification to Fo…
temaotl Jul 22, 2024
42f5791
make notification to FolderDeleteMembership.php (not tested
temaotl Jul 23, 2024
a002d72
rin pint
temaotl Jul 23, 2024
6cb3e98
make delete with observer (no test)
temaotl Jul 23, 2024
f0dfe3a
make better notification in FolderDeleteMembership.php
temaotl Jul 23, 2024
aa9bcb4
fix entity request without entity bug
temaotl Jul 23, 2024
6bb0dc3
make NotificationService.php more abstract
temaotl Jul 23, 2024
f5ecf7c
rewrite notification in FederationController.php to NotificationServi…
temaotl Jul 23, 2024
89a2074
delete old notification in FederationController.php
temaotl Jul 24, 2024
44394f2
fix notification problem
temaotl Jul 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ VITE_PUSHER_PORT="${PUSHER_PORT}"
VITE_PUSHER_SCHEME="${PUSHER_SCHEME}"
VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

MDA_CONFIG_FOLDER=/opt/mda-distribution-0.10.0/config
MDA_SCRIPT=/opt/mda-distribution-0.10.0/mda.sh
EDU_TO_EDUGAIN_FOLDER="eduid2edugain"

[email protected]:repository
GIT_REMOTE_BRANCH=main
GIT_LOCAL=/home/user/metaman/storage/git
Expand All @@ -86,4 +90,4 @@ LDAP_PORT=636
LDAP_BASE_DN="ou=Organizations,dc=example,dc=org"
LDAP_BASE_DN_EDUIDCZORGANIZATIONS="ou=Organizations,o=saml,dc=example,dc=org"
LDAP_SSL=true
LDAP_TLS=false
LDAP_TLS=false
41 changes: 21 additions & 20 deletions app/Console/Commands/DumpFromGit.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace App\Console\Commands;


use App\Facades\EntityFacade;
use App\Models\Entity;
use App\Models\Membership;
use App\Models\User;
use App\Traits\DumpFromGit\CreateCategoriesAndGroupsTrait;
Expand All @@ -14,17 +14,16 @@
use App\Traits\EdugainTrait;
use App\Traits\FederationTrait;
use App\Traits\GitTrait;
use App\Traits\ValidatorTrait;
use Exception;
use Illuminate\Console\Command;
use App\Traits\ValidatorTrait;


class DumpFromGit extends Command
{
use GitTrait, ValidatorTrait;
use CreateFederationTrait,CreateEntitiesTrait,CreateCategoriesAndGroupsTrait;
use UpdateEntity,FederationTrait,FixEntityTrait;
use CreateCategoriesAndGroupsTrait,CreateEntitiesTrait,CreateFederationTrait;
use EdugainTrait;
use FederationTrait,FixEntityTrait,UpdateEntity;
use GitTrait, ValidatorTrait;

/**
* The name and signature of the console command.
Expand All @@ -43,35 +42,37 @@ class DumpFromGit extends Command
private function createMetadataFiles(): void
{
$this->updateFederationFolders();
$membership = Membership::select('entity_id','federation_id')->whereApproved(1)->get();
$membership = Membership::select('entity_id', 'federation_id')->whereApproved(1)->get();
foreach ($membership as $member) {
EntityFacade::saveMetadataToFederationFolder($member->entity_id, $member->federation_id);
}
}


/**
* Execute the console command.
*
* @throws Exception no amin
*/
public function handle()
{
$firstAdminId = User::where('admin', 1)->first()->id;
if(empty($firstAdminId))
if (empty($firstAdminId)) {
throw new Exception('firstAdminId is null');
}

Entity::withoutEvents(function () use ($firstAdminId) {
$this->initializeGit();
$this->createFederations();
$this->createEntities($firstAdminId);
$this->createCategoriesAndGroups();
$this->updateGroupsAndCategories();
$this->updateEntitiesXml();
$this->updateFederationFolders();
$this->fixEntities();
$this->createMetadataFiles();
$this->makeEdu2Edugain();

$this->initializeGit();
$this->createFederations();
$this->createEntities($firstAdminId);
$this->createCategoriesAndGroups();
$this->updateGroupsAndCategories();
$this->updateEntitiesXml();
$this->updateFederationFolders();
$this->fixEntities();
$this->createMetadataFiles();
$this->makeEdu2Edugain();

});

}
}
65 changes: 40 additions & 25 deletions app/Console/Commands/ValidateMetaConsole.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
namespace App\Console\Commands;

use App\Models\Entity;
use App\Models\Federation;
use App\Traits\DumpFromGit\EntitiesHelp\FixEntityTrait;
use App\Traits\ValidatorTrait;
use Exception;
use Illuminate\Console\Command;

class ValidateMetaConsole extends Command
Expand All @@ -23,71 +25,84 @@ class ValidateMetaConsole extends Command
*/
protected $description = 'Command description';


use ValidatorTrait,FixEntityTrait;
use FixEntityTrait,ValidatorTrait;

/**
* Execute the console command.
*/

private function doc()
{
foreach (Entity::select()->get() as $entity)
{
foreach (Entity::select()->get() as $entity) {
$ent = Entity::where('id', $entity->id)->select()->first();


// $res = json_decode($this->validateMetadata($ent->metadata),true);
$res = json_decode($this->validateMetadata($ent->xml_file,true),true);
$res = json_decode($this->validateMetadata($ent->xml_file, true), true);
$res['ent_id'] = $ent->id;
$errorArray = $res['errorArray'];


if($res['code']==1)
{
if ($res['code'] == 1) {
dump($res);
}
else
{
} else {
dump($res['ent_id']);
}
}
}

private function meta()
{
foreach (Entity::select()->get() as $entity)
{
foreach (Entity::select()->get() as $entity) {

$ent = Entity::where('id', $entity->id)->select()->first();

$curr = 345;

if($ent->id < $curr)
if ($ent->id < $curr) {
continue;
if($ent->id > $curr)
}
if ($ent->id > $curr) {
break;
}


$res = json_decode($this->validateMetadata($ent->metadata),true);
$res = json_decode($this->validateMetadata($ent->metadata), true);
$res['ent_id'] = $ent->id;


dump($res);
if( $res['code']==1)
{
if ($res['code'] == 1) {

}
}
}

private function runMDA(Federation $federation)
{
$filterArray = explode(', ', $federation->filters);

$scriptPath = config('storageCfg.mdaScript');
$command = 'sh '.config('storageCfg.mdaScript');

$realScriptPath = realpath($scriptPath);

if ($realScriptPath === false) {
throw new Exception('file not exist'.$scriptPath);
}

foreach ($filterArray as $filter) {
$file = escapeshellarg($filter).'.xml';
$pipeline = 'main';
$command = 'sh '.escapeshellarg($realScriptPath).' '.$file.' '.$pipeline;

$res = shell_exec($command);
dump($res);
}
}

public function handle()
{
$federation = Federation::where('id', 1)->first();
$this->runMDA($federation);

// $this->fixEntities();
$this->doc();

// $this->fixEntities();
// $this->doc();

}
}
1 change: 0 additions & 1 deletion app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ class Kernel extends ConsoleKernel
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
Expand Down
7 changes: 1 addition & 6 deletions app/Events/FederationApprove.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@
namespace App\Events;

use App\Models\Federation;
use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;

Expand All @@ -20,9 +16,8 @@ class FederationApprove
/**
* Create a new event instance.
*/
public function __construct(Federation $federation)
public function __construct(Federation $federation)
{
$this->federation = $federation;
}

}
4 changes: 0 additions & 4 deletions app/Http/Controllers/CategoryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ public function store(StoreCategory $request)
/**
* Display the specified resource.
*
* @param \App\Models\Category $category
* @return \Illuminate\Http\Response
*/
public function show(Category $category)
Expand All @@ -92,7 +91,6 @@ public function show(Category $category)
/**
* Show the form for editing the specified resource.
*
* @param \App\Models\Category $category
* @return \Illuminate\Http\Response
*/
public function edit(Category $category)
Expand All @@ -108,7 +106,6 @@ public function edit(Category $category)
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param \App\Models\Category $category
* @return \Illuminate\Http\Response
*/
public function update(UpdateCategory $request, Category $category)
Expand All @@ -134,7 +131,6 @@ public function update(UpdateCategory $request, Category $category)
/**
* Remove the specified resource from storage.
*
* @param \App\Models\Category $category
* @return \Illuminate\Http\Response
*/
public function destroy(Category $category)
Expand Down
Loading