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 ofSolrRequest
s.- Author:
- Kelly Tisdell (ktisdell)
-
-
Field Summary
Fields Modifier and Type Field Description static String
CLUSTER_STATUS_PATH
-
Constructor Summary
Constructors Constructor Description AbstractBasicAuthAwareSolrProvider(org.apache.solr.client.solrj.SolrClient solrClient, String solrUserName, String solrPassword)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected List<String>
determineCollectionsFromAliases(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
getSolrClient()
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 Detail
-
CLUSTER_STATUS_PATH
public static final String CLUSTER_STATUS_PATH
- See Also:
- Constant Field Values
-
-
Method Detail
-
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
-
-