Class AbstractBasicAuthAwareSolrProvider

java.lang.Object
com.broadleafcommerce.search.provider.solr.AbstractBasicAuthAwareSolrProvider
All Implemented Interfaces:
SolrProvider
Direct Known Subclasses:
DefaultSolrCloudAdminProvider, DefaultSolrReindexProvider, DefaultSolrSearchProvider

public abstract class AbstractBasicAuthAwareSolrProvider extends Object implements SolrProvider
Abstract class that provides convenience methods to allow implementors to arbitrarily set BasicAuth credentials on various types of SolrRequests.
Author:
Kelly Tisdell (ktisdell)
  • Field Details

  • Constructor Details

    • AbstractBasicAuthAwareSolrProvider

      public AbstractBasicAuthAwareSolrProvider(org.apache.solr.client.solrj.SolrClient solrClient, @Nullable String solrUserName, @Nullable String solrPassword)
  • Method Details

    • getSolrClient

      public org.apache.solr.client.solrj.SolrClient getSolrClient()
      Description copied from interface: SolrProvider
      Get a client to make requests to Solr.
      Specified by:
      getSolrClient in interface SolrProvider
      Returns:
      a client to make requests to Solr
    • getSolrBasicAuthUser

      @Nullable protected String getSolrBasicAuthUser(org.apache.solr.client.solrj.SolrRequest<?> request)
      Returns a BasicAuth username for Solr. The request parameter allows implementors to override this and provide different credentials for different types of requests. By default this uses the parameters passed to the constructor. This can return null, in which case no BasicAuth credentials will be set.

      Typically the requests will be one of QueryRequest, UpdateRequest, CollectionAdminRequest, or CoreAdminRequest. Implementors can decide whether they want to use different passwords for different types of requests. By default the userName provided in the constructor are returned.

      Parameters:
      request - The request for which to get the basic auth user
      Returns:
      The Solr basic auth user, or null if none
    • getSolrBasicAuthPassword

      @Nullable protected String getSolrBasicAuthPassword(org.apache.solr.client.solrj.SolrRequest<?> request)
      Returns a BasicAuth password for Solr. The request parameter allows implementors to override this and provide different credentials for different types of requests. By default this uses the parameters passed to the constructor. This can return null.

      Typically the requests will be one of QueryRequest, UpdateRequest, CollectionAdminRequest, or CoreAdminRequest. Implementors can decide whether they want to use different passwords for different types of requests. By default the password provided in the constructor are returned.

      Parameters:
      request - The request for which to get the basic auth password
      Returns:
      The Solr basic auth password, or null if none
    • setBasicAuthCredentialsIfNecessary

      protected <T extends org.apache.solr.client.solrj.SolrResponse> org.apache.solr.client.solrj.SolrRequest<T> setBasicAuthCredentialsIfNecessary(org.apache.solr.client.solrj.SolrRequest<T> request)
      Allows implementors to pass any SolrRequest here to optionally call the SolrRequest.setBasicAuthCredentials(String, String). If the userName is null, then this is skipped.
      Parameters:
      request - The request on which to set the basic auth credentials
    • reloadCollectionsFromAliases

      protected void reloadCollectionsFromAliases(String... aliases) throws org.apache.solr.client.solrj.SolrServerException, IOException
      Reload the collections associated with supplied aliases. Required after updating synonyms or stopwords.
      Parameters:
      aliases - The aliases to reload
      Throws:
      org.apache.solr.client.solrj.SolrServerException
      IOException
    • reloadCollections

      protected void reloadCollections(Collection<String> collections) throws org.apache.solr.client.solrj.SolrServerException, IOException
      Throws:
      org.apache.solr.client.solrj.SolrServerException
      IOException
    • determineCollectionsFromAliases

      protected List<String> determineCollectionsFromAliases(String[] aliases) throws org.apache.solr.client.solrj.SolrServerException, IOException
      Throws:
      org.apache.solr.client.solrj.SolrServerException
      IOException