You are here

class AcquiaSearchService in Acquia Search 6.3

Hierarchy

Expanded class hierarchy of AcquiaSearchService

3 string references to 'AcquiaSearchService'
AcquiaSearchWebTestCase::testEnvironment in tests/acquia_search.test
Tests Acquia Search environment creation.
acquia_search_environment_connected in ./acquia_search.module
Tests whether the environment is connected to Acquia Search.
acquia_search_get_environment in ./acquia_search.module
Predefined Acquia Search network environment

File

./Acquia_Search_Service.php, line 9

View source
class AcquiaSearchService extends DrupalApacheSolrService {

  /**
   * Send an optimize command.
   *
   * We want to control the schedule of optimize commands ourselves,
   * so do a method override to make ->optimize() a no-op.
   *
   * @see Drupal_Apache_Solr_Service::optimize()
   */
  public function optimize($waitFlush = true, $waitSearcher = true, $timeout = 3600) {
    return TRUE;
  }

  /**
   * Modify the url and add headers appropriate to authenticate to Acquia Search.
   *
   * @return
   *  The nonce used in the request.
   */
  protected function prepareRequest(&$url, &$options, $use_data = TRUE) {
    module_load_include('inc', 'acquia_agent', 'acquia_agent_streams');
    $id = uniqid();
    if (!stristr($url, '?')) {
      $url .= "?";
    }
    else {
      $url .= "&";
    }
    $url .= 'request_id=' . $id;
    if ($use_data && isset($options['data'])) {
      list($cookie, $nonce) = acquia_search_auth_cookie($url, $options['data'], NULL, $this->env_id);
    }
    else {
      list($cookie, $nonce) = acquia_search_auth_cookie($url, NULL, NULL, $this->env_id);
    }
    if (empty($cookie)) {
      throw new Exception('Invalid authentication string - subscription keys expired or missing.');
    }
    $options['headers']['Cookie'] = $cookie;
    $options['headers'] += array(
      'User-Agent' => 'acquia_search/' . variable_get('acquia_search_version', '6.x-3.x'),
    );
    $options['context'] = acquia_agent_stream_context_create($url, 'acquia_search');
    if (!$options['context']) {
      throw new Exception(t("Could not create stream context"));
    }
    return $nonce;
  }

  /**
   * Validate the hmac for the response body.
   *
   * @return
   *  The response object.
   */
  protected function authenticateResponse($response, $nonce, $url) {
    $hmac = acquia_search_extract_hmac($response->headers);
    if (!acquia_search_valid_response($hmac, $nonce, $response->data, NULL, $this->env_id)) {
      throw new Exception('Authentication of search content failed url: ' . $url);
    }
    return $response;
  }

  /**
   * Make a request to a servlet (a path) that's not a standard path.
   *
   * @override
   */
  public function makeServletRequest($servlet, $params = array(), $options = array()) {

    // Add default params.
    $params += array(
      'wt' => 'json',
    );
    $url = $this
      ->_constructUrl($servlet, $params);

    // We assume we only authenticate the URL for other servlets.
    $nonce = $this
      ->prepareRequest($url, $options, FALSE);
    $response = $this
      ->_makeHttpRequest($url, $options);
    $response = $this
      ->checkResponse($response);
    return $this
      ->authenticateResponse($response, $nonce, $url);
  }

  /**
   * Central method for making a GET operation against this Solr Server
   *
   * @override
   */
  protected function _sendRawGet($url, $options = array()) {
    $nonce = $this
      ->prepareRequest($url, $options);
    $response = $this
      ->_makeHttpRequest($url, $options);
    $response = $this
      ->checkResponse($response);
    return $this
      ->authenticateResponse($response, $nonce, $url);
  }

  /**
   * Central method for making a POST operation against this Solr Server
   *
   * @override
   */
  protected function _sendRawPost($url, $options = array()) {
    $options['method'] = 'POST';

    // Normally we use POST to send XML documents.
    if (!isset($options['headers']['Content-Type'])) {
      $options['headers']['Content-Type'] = 'text/xml; charset=UTF-8';
    }
    $nonce = $this
      ->prepareRequest($url, $options);
    $response = $this
      ->_makeHttpRequest($url, $options);
    $response = $this
      ->checkResponse($response);
    return $this
      ->authenticateResponse($response, $nonce, $url);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AcquiaSearchService::authenticateResponse protected function Validate the hmac for the response body.
AcquiaSearchService::makeServletRequest public function Make a request to a servlet (a path) that's not a standard path. Overrides DrupalApacheSolrService::makeServletRequest
AcquiaSearchService::optimize public function Send an optimize command. Overrides DrupalApacheSolrService::optimize
AcquiaSearchService::prepareRequest protected function Modify the url and add headers appropriate to authenticate to Acquia Search.
AcquiaSearchService::_sendRawGet protected function Central method for making a GET operation against this Solr Server Overrides DrupalApacheSolrService::_sendRawGet
AcquiaSearchService::_sendRawPost protected function Central method for making a POST operation against this Solr Server Overrides DrupalApacheSolrService::_sendRawPost
DrupalApacheSolrService::$env_id protected property
DrupalApacheSolrService::$luke protected property
DrupalApacheSolrService::$parsed_url protected property Server url
DrupalApacheSolrService::$soft_commit protected property Flag that denotes whether to use soft commits for Solr 4.x, defaults to FALSE.
DrupalApacheSolrService::$stats protected property
DrupalApacheSolrService::$system_info protected property
DrupalApacheSolrService::$update_url protected property Constructed servlet full path URLs
DrupalApacheSolrService::$_defaultTimeout protected property Default HTTP timeout when one is not specified (initialized to default_socket_timeout ini setting)
DrupalApacheSolrService::addDocuments public function Add an array of Solr Documents to the index all at once Overrides DrupalApacheSolrServiceInterface::addDocuments
DrupalApacheSolrService::checkResponse protected function Check the reponse code and thow an exception if it's not 200.
DrupalApacheSolrService::clearCache public function Clear cached Solr data. Overrides DrupalApacheSolrServiceInterface::clearCache
DrupalApacheSolrService::commit public function Send a commit command. Will be synchronous unless both wait parameters are set to false. Overrides DrupalApacheSolrServiceInterface::commit
DrupalApacheSolrService::deleteById public function Create a delete document based on document ID Overrides DrupalApacheSolrServiceInterface::deleteById
DrupalApacheSolrService::deleteByMultipleIds public function Create and post a delete document based on multiple document IDs. Overrides DrupalApacheSolrServiceInterface::deleteByMultipleIds
DrupalApacheSolrService::deleteByQuery public function Create a delete document based on a query and submit it Overrides DrupalApacheSolrServiceInterface::deleteByQuery
DrupalApacheSolrService::drupal_apachesolr_hash_base64 private function
DrupalApacheSolrService::escape public static function Escape a value for special query characters such as ':', '(', ')', '*', '?', etc.
DrupalApacheSolrService::escapePhrase public static function Escape a value meant to be contained in a phrase for special query characters
DrupalApacheSolrService::getFields public function Get just the field meta-data about the index. Overrides DrupalApacheSolrServiceInterface::getFields
DrupalApacheSolrService::getId function Overrides DrupalApacheSolrServiceInterface::getId
DrupalApacheSolrService::getLuke public function Get meta-data about the index. Overrides DrupalApacheSolrServiceInterface::getLuke
DrupalApacheSolrService::getSoftCommit public function Returns the flag that denotes whether to use soft commits for Solr 4.x.
DrupalApacheSolrService::getSolrVersion public function
DrupalApacheSolrService::getStats public function Get information about the Solr Core. Overrides DrupalApacheSolrServiceInterface::getStats
DrupalApacheSolrService::getStatsSummary public function Get summary information about the Solr Core. Overrides DrupalApacheSolrServiceInterface::getStatsSummary
DrupalApacheSolrService::getSystemInfo public function Get information about the Solr Core. Overrides DrupalApacheSolrServiceInterface::getSystemInfo
DrupalApacheSolrService::getUrl public function Get the Solr url Overrides DrupalApacheSolrServiceInterface::getUrl
DrupalApacheSolrService::httpBuildQuery protected function Like PHP's built in http_build_query(), but uses rawurlencode() and no [] for repeated params.
DrupalApacheSolrService::LUKE_SERVLET constant
DrupalApacheSolrService::NAMED_LIST_FORMAT constant How NamedLists should be formatted in the output. This specifically effects facet counts. Valid values are 'map' (default) or 'flat'.
DrupalApacheSolrService::phrase public static function Convenience function for creating phrase syntax from a value
DrupalApacheSolrService::ping public function Call the /admin/ping servlet, to test the connection to the server. Overrides DrupalApacheSolrServiceInterface::ping
DrupalApacheSolrService::PING_SERVLET constant Servlet mappings
DrupalApacheSolrService::search public function Simple Search interface Overrides DrupalApacheSolrServiceInterface::search
DrupalApacheSolrService::SEARCH_SERVLET constant
DrupalApacheSolrService::setLuke protected function Sets $this->luke with the meta-data about the index from admin/luke.
DrupalApacheSolrService::setSoftCommit public function Flags whether to use soft commits for Solr 4.x.
DrupalApacheSolrService::setStats protected function Sets $this->stats with the information about the Solr Core form
DrupalApacheSolrService::setSystemInfo protected function Call the /admin/system servlet
DrupalApacheSolrService::setUrl public function Set the Solr url. Overrides DrupalApacheSolrServiceInterface::setUrl
DrupalApacheSolrService::STATS_SERVLET constant
DrupalApacheSolrService::STATS_SERVLET_4 constant
DrupalApacheSolrService::SYSTEM_SERVLET constant
DrupalApacheSolrService::update public function Raw update Method. Takes a raw post body and sends it to the update service. Post body should be a complete and well formed xml document. Overrides DrupalApacheSolrServiceInterface::update
DrupalApacheSolrService::UPDATE_SERVLET constant
DrupalApacheSolrService::_clearCache protected function
DrupalApacheSolrService::_constructUrl protected function Return a valid http URL given this server's host, port and path and a provided servlet name
DrupalApacheSolrService::_makeHttpRequest protected function Central method for making the actual http request to the Solr Server
DrupalApacheSolrService::__construct public function Constructor Overrides DrupalApacheSolrServiceInterface::__construct