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 ofSolrRequests.- Author:
- Kelly Tisdell (ktisdell)
-
-
Field Summary
Fields Modifier and Type Field Description static StringCLUSTER_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 StringgetSolrBasicAuthPassword(org.apache.solr.client.solrj.SolrRequest<?> request)Returns a BasicAuth password for Solr.protected StringgetSolrBasicAuthUser(org.apache.solr.client.solrj.SolrRequest<?> request)Returns a BasicAuth username for Solr.org.apache.solr.client.solrj.SolrClientgetSolrClient()Get a client to make requests to Solr.protected voidreloadCollections(Collection<String> collections)protected voidreloadCollectionsFromAliases(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 anySolrRequesthere 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:SolrProviderGet a client to make requests to Solr.- Specified by:
getSolrClientin 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 anySolrRequesthere 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.SolrServerExceptionIOException
-
reloadCollections
protected void reloadCollections(Collection<String> collections) throws org.apache.solr.client.solrj.SolrServerException, IOException
- Throws:
org.apache.solr.client.solrj.SolrServerExceptionIOException
-
determineCollectionsFromAliases
protected List<String> determineCollectionsFromAliases(String[] aliases) throws org.apache.solr.client.solrj.SolrServerException, IOException
- Throws:
org.apache.solr.client.solrj.SolrServerExceptionIOException
-
-