/** * 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(); $days = $this->getContainer()->getParameter('days_silent'); $journals = $em->getRepository('AppBundle:Journal')->findSilent($days); $count = count($journals); $this->logger->notice("Found {$count} silent journals."); if (count($journals) === 0) { return; } $users = $em->getRepository('AppUserBundle:User')->findUserToNotify(); if (count($users) === 0) { $this->logger->error('No users to notify.'); return; } $this->sendNotifications($days, $users, $journals); foreach ($journals as $journal) { if ($this->pingJournal($journal)) { $this->logger->notice("Ping Success {$journal->getUrl()})"); $journal->setStatus('healthy'); $journal->setContacted(new DateTime()); } else { $journal->setStatus('unhealthy'); $journal->setNotified(new DateTime()); } } if (!$input->getOption('dry-run')) { $em->flush(); } }
/** * {@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(); } }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $state = $input->getArgument('state'); $uuids = $input->getArgument('deposit'); $deposits = $this->getDeposits($uuids); foreach ($deposits as $deposit) { $this->logger->notice("Setting {$deposit->getDepositUuid()} to {$state}"); $deposit->setState($state); if ($input->getOption('clear')) { $deposit->setErrorLog(array()); $deposit->setPackageSize(null); $deposit->setPlnState(null); $deposit->setProcessingLog(''); $deposit->addToProcessingLog('Deposit reset.'); $deposit->setAuContainer(null); } } $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(); $days = $this->getContainer()->getParameter('days_reminder'); $journals = $em->getRepository('AppBundle:Journal')->findOverdue($days); $count = count($journals); $this->logger->notice("Found {$count} overdue journals."); if (count($journals) === 0) { return; } $users = $em->getRepository('AppUserBundle:User')->findUserToNotify(); if (count($users) === 0) { $this->logger->error('No users to notify.'); return; } $this->sendReminders($days, $users, $journals); foreach ($journals as $journal) { $journal->setNotified(new DateTime()); } if (!$input->getOption('dry-run')) { $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(); } }