Ejemplo n.º 1
0
 /**
  * Tests the connect
  *
  * @dataProvider connectDataProvider
  * @test
  *
  * @param string $host
  * @param string $port
  * @param string $path
  * @param string $scheme
  * @param bool $expectsException
  * @param string $expectedConnectionString
  * @return void
  */
 public function canConnect($host, $port, $path, $scheme, $expectsException, $expectedConnectionString)
 {
     $exceptionOccured = false;
     try {
         $solrService = $this->connectionManager->getConnection($host, $port, $path, $scheme);
         $this->assertEquals($expectedConnectionString, $solrService->__toString());
     } catch (\UnexpectedValueException $exception) {
         $exceptionOccured = true;
     }
     $this->assertEquals($expectsException, $exceptionOccured);
 }
Ejemplo n.º 2
0
 /**
  * Checks whether a Solr server is available and provides some information.
  *
  * @param array $solrConnection Solr connection parameters
  * @return Status Status of the Solr connection
  */
 protected function getConnectionStatus(array $solrConnection)
 {
     $value = 'Your site was unable to contact the Apache Solr server.';
     $severity = Status::ERROR;
     $solr = $this->connectionManager->getConnection($solrConnection['solrHost'], $solrConnection['solrPort'], $solrConnection['solrPath'], $solrConnection['solrScheme']);
     $message = '<ul>' . '<li style="padding-bottom: 10px;">Site: ' . $solrConnection['label'] . '</li>' . '<li>Scheme: ' . $solr->getScheme() . '</li>' . '<li>Host: ' . $solr->getHost() . '</li>' . '<li>Port: ' . $solr->getPort() . '</li>' . '<li style="padding-bottom: 10px;">Path: ' . $solr->getPath() . '</li>';
     $pingQueryTime = $solr->ping();
     if ($pingQueryTime !== FALSE) {
         $severity = Status::OK;
         $value = 'Your site has contacted the Apache Solr server.';
         $solrVersion = $this->formatSolrVersion($solr->getSolrServerVersion());
         $message .= '<li>Apache Solr: ' . $solrVersion . '</li>';
         $message .= '<li>Ping Query Time: ' . (int) ($pingQueryTime * 1000) . 'ms</li>';
         $message .= '<li>schema.xml: ' . $solr->getSchemaName() . '</li>';
         $message .= '<li>solrconfig.xml: ' . $solr->getSolrconfigName() . '</li>';
         $accessFilterPluginStatus = GeneralUtility::makeInstance('Tx_Solr_Report_AccessFilterPluginInstalledStatus');
         $accessFilterPluginVersion = $accessFilterPluginStatus->getInstalledPluginVersion($solr);
         $message .= '<li>Access Filter Plugin: ' . $accessFilterPluginVersion . '</li>';
     }
     $message .= '</ul>';
     return GeneralUtility::makeInstance('TYPO3\\CMS\\Reports\\Status', 'Apache Solr', $value, $message, $severity);
 }
Ejemplo n.º 3
0
 /**
  * Checks for which languages connections have been configured and returns
  * these connections.
  *
  * @param array $translationOverlays An array of translation overlays to check for configured connections.
  * @return array An array of ApacheSolrForTypo3\Solr\SolrService connections.
  */
 protected function getConnectionsForIndexableLanguages(array $translationOverlays)
 {
     $connections = array();
     foreach ($translationOverlays as $translationOverlay) {
         $pageId = $translationOverlay['pid'];
         $languageId = $translationOverlay['sys_language_uid'];
         try {
             $connection = $this->connectionManager->getConnectionByPageId($pageId, $languageId);
             $connections[$languageId] = $connection;
         } catch (NoSolrConnectionFoundException $e) {
             // ignore the exception as we seek only those connections
             // actually available
         }
     }
     return $connections;
 }
Ejemplo n.º 4
0
 /**
  * Finds the Solr connection to use for the currently selected core.
  *
  * @return \ApacheSolrForTypo3\Solr\SolrService Solr connection
  */
 protected function getSelectedCoreSolrConnection()
 {
     $currentCoreConnection = null;
     $solrConnections = $this->connectionManager->getConnectionsBySite($this->site);
     $currentCore = $this->moduleDataStorageService->loadModuleData()->getCore();
     foreach ($solrConnections as $solrConnection) {
         if ($solrConnection->getPath() == $currentCore) {
             $currentCoreConnection = $solrConnection;
             break;
         }
     }
     if (is_null($currentCoreConnection)) {
         // when switching sites $currentCore is empty and nothing matched
         // fall back to the connection's first core
         $currentCoreConnection = $solrConnections[0];
     }
     return $currentCoreConnection;
 }
Ejemplo n.º 5
0
 /**
  * Checks whether a Solr server is available and provides some information.
  *
  * @param array $solrConnection Solr connection parameters
  * @return Status Status of the Solr connection
  */
 protected function getConnectionStatus(array $solrConnection)
 {
     $value = 'Your site has contacted the Apache Solr server.';
     $this->responseStatus = Status::OK;
     $solr = $this->connectionManager->getConnection($solrConnection['solrHost'], $solrConnection['solrPort'], $solrConnection['solrPath'], $solrConnection['solrScheme']);
     $this->responseMessage = $this->getMessageTemplate();
     $this->responseMessage = $this->replaceMarkerInResponse($this->responseMessage, 'SITE', $solrConnection['label']);
     $this->responseMessage = $this->replaceMarkerInResponse($this->responseMessage, 'SCHEME', $solr->getScheme());
     $this->responseMessage = $this->replaceMarkerInResponse($this->responseMessage, 'HOST', $solr->getHost());
     $this->responseMessage = $this->replaceMarkerInResponse($this->responseMessage, 'PATH', $solr->getPath());
     $this->responseMessage = $this->replaceMarkerInResponse($this->responseMessage, 'PORT', $solr->getPort());
     $this->checkSolrVersion($solr);
     $this->checkAccessFilter($solr);
     $this->checkPingTime($solr);
     $this->checkSolrConfigName($solr);
     $this->checkSolrSchemaName($solr);
     if ($this->responseStatus !== Status::OK) {
         $value = 'Failed contacting the Solr server.';
     }
     return GeneralUtility::makeInstance('TYPO3\\CMS\\Reports\\Status', 'Apache Solr', $value, $this->responseMessage, $this->responseStatus);
 }