Class AbstractBasicAuthAwareSolrProvider
java.lang.Object
com.broadleafcommerce.search.provider.solr.AbstractBasicAuthAwareSolrProvider
- All Implemented Interfaces:
SolrProvider
- Direct Known Subclasses:
DefaultSolrCloudAdminProvider
,DefaultSolrReindexProvider
,DefaultSolrSearchProvider
Abstract class that provides convenience methods to allow implementors to arbitrarily set
BasicAuth credentials on various types of
SolrRequest
s.- Author:
- Kelly Tisdell (ktisdell)
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionAbstractBasicAuthAwareSolrProvider
(org.apache.solr.client.solrj.SolrClient solrClient, String solrUserName, String solrPassword) -
Method Summary
Modifier and TypeMethodDescriptiondetermineCollectionsFromAliases
(String[] aliases) protected String
getSolrBasicAuthPassword
(org.apache.solr.client.solrj.SolrRequest<?> request) Returns a BasicAuth password for Solr.protected String
getSolrBasicAuthUser
(org.apache.solr.client.solrj.SolrRequest<?> request) Returns a BasicAuth username for Solr.org.apache.solr.client.solrj.SolrClient
Get a client to make requests to Solr.protected void
reloadCollections
(Collection<String> collections) protected void
reloadCollectionsFromAliases
(String... aliases) Reload the collections associated with supplied aliases.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 anySolrRequest
here to optionally call theSolrRequest.setBasicAuthCredentials(String, String)
.
-
Field Details
-
CLUSTER_STATUS_PATH
- See Also:
-
-
Constructor Details
-
AbstractBasicAuthAwareSolrProvider
-
-
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 interfaceSolrProvider
- 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
, orCoreAdminRequest
. 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
, orCoreAdminRequest
. 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 anySolrRequest
here to optionally call theSolrRequest.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
-