diff -r 338bcc78d431 -r ded3cf22eef8 server/src/app/Console/Commands/ManageHandle.php --- a/server/src/app/Console/Commands/ManageHandle.php Fri Apr 22 11:20:17 2016 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,116 +0,0 @@ -documentRepository = $documentRepository; - parent::__construct(); - } - - private function registerHandle($doc) { - - } - - /** - * Execute the console command. - * - * @return mixed - */ - public function handle() - { - $stepSize = $this->option('step-size'); - - $passwordKey = $this->option('password'); - if($this->option('ask-password')) { - $password = $this->secret('Private key password?'); - } - - $privateKey = $this->option('key'); - - $privateKeyRes = openssl_pkey_get_private($privateKey, $password); - - - // create handle client - $this->handleClient = new HandleClient($privateKeyRes); - - $this->info('Adding documents handles...'); - - $lastPage = $this->documentRepository->paginateAll($stepSize, 'page')->lastPage(); - $total = $this->documentRepository->getCount(); - - $progressBar = $this->output->createProgressBar($total); - $progressBar->setFormat(' %current%/%max% [%bar%] %percent:3s%% - %message%'); - - for ($page=1;$page<=$lastPage;$page++) - { - $docs = $this->documentRepository->paginateAll($stepSize, 'page', $page); - foreach ($docs as $doc){ - $this->registerHandle($doc); - $progressBar->setMessage($doc->getId()); - $progressBar->advance(); - } - } - $progressBar->finish(); - $this->info('Adding handles completed'); - - $this->info('Removing extra handles...'); - - $lastPage = -1; - $page = 0; - $lastPage = 0; - - while($lastPage<0 || $page <= $lastPage) { - $handle_res = $this->handleClient->paginateAll($stepSize, 'page', $page++); - foreach($handle_res as $handle) { - if(is_null($this->documentRepository->get($handle))) { - $this->handleClient->deleteHandle($handle); - } - $progressBar->setMessage($handle); - $progressBar->advance(); - } - } - - $this->info('Removing extra handles completed'); - - - // query ids - // loop on ids - // PUT handle - // query handle - // if not in rdf ids delete - - // delete handle session - } -}