public function execute() { $node_repository = tx_caretaker_NodeRepository::getInstance(); $node = $node_repository->id2node($this->node_id); if (!$node) { return false; } $lockObj = t3lib_div::makeInstance('t3lib_lock', 'tx_caretaker_update_' . $node->getCaretakerNodeId(), $GLOBALS['TYPO3_CONF_VARS']['SYS']['lockingMode']); // no output during scheduler runs tx_caretaker_ServiceHelper::unregisterCaretakerNotificationService('CliNotificationService'); if ($lockObj->acquire()) { $node->updateTestResult(); $lockObj->release(); } else { return false; } // send aggregated notifications $notificationServices = tx_caretaker_ServiceHelper::getAllCaretakerNotificationServices(); foreach ($notificationServices as $notificationService) { $notificationService->sendNotifications(); } $success = true; return $success; }
/** * @param array $argv */ public function cli_main($argv) { $task = (string) $this->cli_args['_DEFAULT'][1]; if (!$task) { $this->cli_validateArgs(); $this->cli_help(); exit; } if ($task == 'update' || $task == 'get' || $task == 'ack' || $task == 'due') { $force = (bool) $this->readArgument('--force', '-f'); $return_status = (bool) $this->readArgument('-r'); $options = array('forceUpdate' => $force); $options = array_merge($options, $this->parseOptions($this->readArgument('--options', '-o'))); $node = FALSE; $node_repository = tx_caretaker_NodeRepository::getInstance(); $nodeId = $this->readArgument('--node', '-N'); if ((bool) $this->readArgument('--root', '-R')) { $node = $node_repository->getRootNode(); } else { if ($nodeId) { $node = $node_repository->id2node($nodeId); } } if ($node) { $this->cli_echo('node ' . $node->getCaretakerNodeId() . chr(10)); $result = FALSE; if ($task == 'update' || $task == 'ack' || $task == 'due') { try { $lockObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Locking\\Locker', 'tx_caretaker_update_' . $node->getCaretakerNodeId(), $GLOBALS['TYPO3_CONF_VARS']['SYS']['lockingMode']); $lockIsAquired = $lockObj->acquire(); } catch (Exception $e) { $this->cli_echo('lock ' . 'tx_caretaker_update_' . $node->getCaretakerNodeId() . ' could not be aquired!' . chr(10) . $e->getMessage()); exit; } if ($lockIsAquired) { if ($task == 'update') { $result = $node->updateTestResult($options); } else { if ($task == 'ack' && is_a($node, 'tx_caretaker_TestNode')) { $result = $node->setModeAck(); } else { if ($task == 'due' && is_a($node, 'tx_caretaker_TestNode')) { $result = $node->setModeDue(); } } } $lockObj->release(); } else { $result = false; $this->cli_echo('node ' . $node->getCaretakerNodeId() . ' is locked because of other running update processes!' . chr(10)); exit; } } if ($task == 'get') { $result = $node->getTestResult(); $this->cli_echo($node->getTitle() . ' [' . $node->getCaretakerNodeId() . ']' . chr(10)); $this->cli_echo($result->getLocallizedStateInfo() . ' [' . $node->getCaretakerNodeId() . ']' . chr(10)); } // send aggregated notifications $notificationServices = tx_caretaker_ServiceHelper::getAllCaretakerNotificationServices(); /** @var tx_caretaker_NotificationBaseExitPoint $notificationService */ foreach ($notificationServices as $notificationService) { $notificationService->sendNotifications(); } if ($return_status) { exit((int) $result->getState()); } else { exit; } } else { $this->cli_echo('Node not found or inactive' . chr(10)); exit; } } elseif ($task == 'update-typo3-latest-version-list') { $result = tx_caretaker_LatestVersionsHelper::updateLatestTypo3VersionRegistry(); $this->cli_echo('TYPO3 latest version list update result: ' . $result . chr(10)); $versions = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Registry')->get('tx_caretaker', 'TYPO3versions'); foreach ($versions as $key => $version) { $this->cli_echo($key . ' => ' . $version . chr(10)); } } if ($task == 'help') { $this->cli_validateArgs(); $this->cli_help(); exit; } }
/** * Send a notification to all registered notification services * * @param string $event * @param tx_caretaker_NodeResult $result * @param tx_caretaker_NodeResult $lastResult */ public function notify($event, $result = NULL, $lastResult = NULL) { // find all registered notification services $notificationServices = tx_caretaker_ServiceHelper::getAllCaretakerNotificationServices(); /** @var tx_caretaker_AbstractNotificationService $notificationService */ foreach ($notificationServices as $notificationService) { $notificationService->addNotification($event, $this, $result, $lastResult); } }
public function ajaxNodeSetDue($params, &$ajaxObj) { $node_id = t3lib_div::_GP('node'); $node_repository = tx_caretaker_NodeRepository::getInstance(); if ($node_id && ($node = $node_repository->id2node($node_id, true))) { if (is_a($node, 'tx_caretaker_TestNode')) { $result = $node->setModeDue(); $content = array('state' => $result->getState(), 'state_info' => $result->getStateInfo(), 'timestamp' => $result->getTimestamp(), 'message' => $result->getLocallizedInfotext()); $ajaxObj->setContent($content); $ajaxObj->setContentFormat('jsonbody'); } else { echo "please give a testnode id" . $node_id; } } else { echo "please give a valid node id" . $node_id; } // send aggregated notifications $notificationServices = tx_caretaker_ServiceHelper::getAllCaretakerNotificationServices(); foreach ($notificationServices as $notificationService) { $notificationService->sendNotifications(); } }
/** * @return bool */ public function execute() { $node_repository = tx_caretaker_NodeRepository::getInstance(); $node = $node_repository->id2node($this->node_id); if (!$node) { return false; } if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['lockingMode'] != 'disable') { $lockObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Locking\\Locker', 'tx_caretaker_update_' . $node->getCaretakerNodeId(), $GLOBALS['TYPO3_CONF_VARS']['SYS']['lockingMode']); // no output during scheduler runs tx_caretaker_ServiceHelper::unregisterCaretakerNotificationService('CliNotificationService'); if ($lockObj->acquire()) { $node->updateTestResult(); $lockObj->release(); } else { return false; } } else { $node->updateTestResult(); } // send aggregated notifications $notificationServices = tx_caretaker_ServiceHelper::getAllCaretakerNotificationServices(); /** @var tx_caretaker_AbstractNotificationService $notificationService */ foreach ($notificationServices as $notificationService) { $notificationService->sendNotifications(); } return true; }
/** * @param array $params * @param \TYPO3\CMS\Core\Http\AjaxRequestHandler $ajaxObj */ public function ajaxNodeSetDue($params, &$ajaxObj) { $node_id = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('node'); $node_repository = tx_caretaker_NodeRepository::getInstance(); $node = $node_repository->id2node($node_id, true); if ($node_id && $node) { if ($node instanceof tx_caretaker_TestNode) { /** @var tx_caretaker_TestNode $node */ $result = $node->setModeDue(); $content = array('state' => $result->getState(), 'state_info' => $result->getStateInfo(), 'timestamp' => $result->getTimestamp(), 'message' => $result->getLocallizedInfotext()); $ajaxObj->setContent($content); $ajaxObj->setContentFormat('jsonbody'); } else { echo "please give a testnode id" . $node_id; } } else { echo "please give a valid node id" . $node_id; } // send aggregated notifications $notificationServices = tx_caretaker_ServiceHelper::getAllCaretakerNotificationServices(); /** @var tx_caretaker_NotificationServiceInterface $notificationService */ foreach ($notificationServices as $notificationService) { $notificationService->sendNotifications(); } }