/**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     /** @var DepositRepository $repo */
     $repo = $this->em->getRepository('AppBundle:Deposit');
     $deposits = $repo->findAll();
     foreach ($deposits as $deposit) {
         $this->logger->notice("{$deposit->getDepositUuid()}");
         $checksum = strtoupper($this->getChecksum($deposit));
         if ($checksum !== $deposit->getChecksumValue()) {
             $this->logger->warning("Updating checksum for {$deposit->getDepositUuid()}");
             $deposit->setChecksumValue($checksum);
         }
     }
     if (!$input->getOption('dry-run')) {
         $this->em->flush();
     }
 }
 /**
  * Execute the runall command, which executes all the commands.
  *
  * @param InputInterface  $input
  * @param OutputInterface $output
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $em = $this->getContainer()->get('doctrine')->getManager();
     $router = $this->getContainer()->get('router');
     $bwlist = $this->getContainer()->get('blackwhitelist');
     $ping = $this->getContainer()->get('ping');
     $ping->setLogger($this->logger);
     /*
      * @var Journal[]
      */
     $journals = $em->getRepository('AppBundle:Journal')->findAll();
     $minVersion = $input->getArgument('minVersion');
     if (!$minVersion) {
         $minVersion = $this->getContainer()->getParameter('min_ojs_version');
     }
     $all = $input->getOption('all');
     $count = count($journals);
     $i = 0;
     foreach ($journals as $journal) {
         ++$i;
         $fmt = sprintf('%5d', $i);
         $url = $router->generate('journal_show', array('id' => $journal->getId()), UrlGeneratorInterface::ABSOLUTE_URL);
         $uuid = $journal->getUuid();
         if (!$all && $journal->getStatus() === 'ping-error') {
             $this->logger->notice("{$fmt}/{$count} - skipped (previous ping-error) - - {$journal->getUrl()}");
             continue;
         }
         if (!$all && $bwlist->isWhitelisted($uuid)) {
             $this->logger->notice("{$fmt}/{$count} - skipped (whitelisted) - - {$journal->getUrl()}");
             continue;
         }
         if (!$all && $bwlist->isBlacklisted($uuid)) {
             $this->logger->notice("{$fmt}/{$count} - skipped (blacklisted) - - {$journal->getUrl()}");
             continue;
         }
         try {
             $response = $ping->ping($journal);
         } catch (Exception $e) {
             $this->logger->error("Ping - HTTP ERROR: {$e->getMessage()} - {$journal->getUrl()} - {$url}");
             $journal->setStatus('ping-error');
             $em->flush($journal);
             continue;
         }
         if ($response->getHttpStatus() !== 200) {
             $this->logger->error("Ping - HTTP {$response->getHttpStatus()} - - {$journal->getUrl()} - {$url} - {$response->getError()}");
             $journal->setStatus('ping-error');
             $em->flush($journal);
             continue;
         }
         if (!$response->getOjsRelease()) {
             $this->logger->warning("Ping - HTTP {$response->getHttpStatus()} - no version number found - {$journal->getUrl()} - {$url}");
             $journal->setStatus('ping-error');
             $em->flush($journal);
             continue;
         }
         $this->logger->notice("Ping - {$response->getHttpStatus()} - {$response->getOjsRelease()} - {$journal->getUrl()} - {$url}");
         if (version_compare($response->getOjsRelease(), $minVersion, '<')) {
             continue;
         }
         if ($input->getOption('dry-run')) {
             continue;
         }
         if ($bwlist->isWhitelisted($uuid) || $bwlist->isBlacklisted($uuid)) {
             continue;
         }
         $whitelist = new Whitelist();
         $whitelist->setUuid($journal->getUuid());
         $whitelist->setComment("{$journal->getUrl()} added automatically by ping-whitelist command.");
         $em->persist($whitelist);
         $em->flush();
     }
 }