Class DefaultTenantResolver
java.lang.Object
com.broadleafcommerce.tenant.service.DefaultTenantResolver
- All Implemented Interfaces:
TenantResolver
Default implementation of
TenantResolver that leverages the UrlResolverProperties
for resolving the admin tenant or application by URL.- Author:
- Nathan Moore (nathanmoore)., Erin Pennington (epenning), Nick Crum (ncrum)
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultTenantResolver(ApplicationService<Application> applicationService, TenantService<Tenant> tenantService, UrlResolverProperties props) -
Method Summary
Modifier and TypeMethodDescriptionconvertLocaleListToCurrencyList(List<Locale> locales) protected org.springframework.web.util.UriComponentsconvertUrlToUri(String url) protected Optional<Application>getApplicationForUri(org.springframework.web.util.UriComponents uri) protected ApplicationService<Application>protected <T> Optional<T>getContextPathMatch(org.springframework.web.util.UriComponents uri, UrlResolverProperties.UrlResolverConfiguration config, BiFunction<String, String, Optional<T>> readByIdentifierAndIdentifierType) protected <T> Optional<T>getDomainMatch(org.springframework.web.util.UriComponents uri, UrlResolverProperties.UrlResolverConfiguration config, BiFunction<String, String, Optional<T>> readByIdentifierAndIdentifierType) protected StringgetDomainPrefix(String domain) protected <T> Optional<T>getMatchForUri(org.springframework.web.util.UriComponents uri, UrlResolverProperties.UrlResolverConfiguration config, BiFunction<String, String, Optional<T>> readByIdentifierAndIdentifierType) Tries to resolve a context result matching the given URI checking for parameters, then domain, then domain prefix.protected <T> Optional<T>getParameterMatch(org.springframework.web.util.UriComponents uri, UrlResolverProperties.UrlResolverConfiguration config, BiFunction<String, String, Optional<T>> readByIdentifierAndIdentifierType) protected <T> Optional<T>getPrefixMatch(org.springframework.web.util.UriComponents uri, UrlResolverProperties.UrlResolverConfiguration config, BiFunction<String, String, Optional<T>> readByIdentifierAndIdentifierType) protected UrlResolverPropertiesgetProps()getTenantForUri(org.springframework.web.util.UriComponents uri) protected TenantService<Tenant>protected booleanisDomainNotMatching(org.springframework.web.util.UriComponents uri, UrlResolverProperties.UrlResolverConfiguration config) protected booleanisEmptyPort(String port) protected booleanisPathNotMatching(org.springframework.web.util.UriComponents uri, UrlResolverProperties.UrlResolverConfiguration config) protected booleanisPortNotMatching(org.springframework.web.util.UriComponents uri, UrlResolverProperties.UrlResolverConfiguration config) protected booleanisPrefixNotMatching(org.springframework.web.util.UriComponents uri, UrlResolverProperties.UrlResolverConfiguration config) protected booleanisSchemeNotMatching(org.springframework.web.util.UriComponents uri, UrlResolverProperties.UrlResolverConfiguration config) resolveAdminTenant(String url) Resolves the tenant for the admin that matches the provided URL, or empty.resolveApplication(String url) Resolves the application that matches the provided URL, or empty.Resolves the application that matches the provided ID.resolveApplicationByToken(String token) Resolves the application that matches the provided token.Resolves the application that matches the provided URL, or empty.protected StringtrimPrefix(String host, String prefix) protected voidupdateAllowedCurrencies(Application application) protected voidupdateAllowedCurrencies(Tenant tenant) protected voidupdateDefaultCurrency(Application application) protected voidupdateDefaultCurrency(Tenant tenant)
-
Constructor Details
-
DefaultTenantResolver
public DefaultTenantResolver(ApplicationService<Application> applicationService, TenantService<Tenant> tenantService, UrlResolverProperties props)
-
-
Method Details
-
resolveApplication
Description copied from interface:TenantResolverResolves the application that matches the provided URL, or empty.- Specified by:
resolveApplicationin interfaceTenantResolver- Parameters:
url- the url to match to an Application- Returns:
- an optional application
-
resolveApplicationByURL
Description copied from interface:TenantResolverResolves the application that matches the provided URL, or empty.- Specified by:
resolveApplicationByURLin interfaceTenantResolver- Parameters:
url- the url to match to an Application- Returns:
- an optional application
-
resolveApplicationById
Description copied from interface:TenantResolverResolves the application that matches the provided ID.- Specified by:
resolveApplicationByIdin interfaceTenantResolver- Parameters:
id- the ID of the application- Returns:
- an optional application
-
resolveApplicationByToken
Description copied from interface:TenantResolverResolves the application that matches the provided token.- Specified by:
resolveApplicationByTokenin interfaceTenantResolver- Parameters:
token- the token of the application- Returns:
- an optional application
-
resolveAdminTenant
Description copied from interface:TenantResolverResolves the tenant for the admin that matches the provided URL, or empty.- Specified by:
resolveAdminTenantin interfaceTenantResolver- Parameters:
url- the url to match to a Tenant- Returns:
- an optional tenant
-
updateDefaultCurrency
-
updateAllowedCurrencies
-
updateDefaultCurrency
-
updateAllowedCurrencies
-
convertLocaleListToCurrencyList
-
convertUrlToUri
-
getApplicationForUri
protected Optional<Application> getApplicationForUri(org.springframework.web.util.UriComponents uri) -
getTenantForUri
-
getMatchForUri
protected <T> Optional<T> getMatchForUri(org.springframework.web.util.UriComponents uri, UrlResolverProperties.UrlResolverConfiguration config, BiFunction<String, String, Optional<T>> readByIdentifierAndIdentifierType) Tries to resolve a context result matching the given URI checking for parameters, then domain, then domain prefix.- Type Parameters:
T- The type of the context domain result to resolve- Parameters:
uri- The requested URI for which to resolve the context domain resultconfig- the url resolver configurationreadByIdentifierAndIdentifierType- The function to read the context domain result given the identifier andResolutionIdentifierType- Returns:
- Optional containing resolved context domain result if found
-
getParameterMatch
protected <T> Optional<T> getParameterMatch(org.springframework.web.util.UriComponents uri, UrlResolverProperties.UrlResolverConfiguration config, BiFunction<String, String, Optional<T>> readByIdentifierAndIdentifierType) -
getDomainMatch
protected <T> Optional<T> getDomainMatch(org.springframework.web.util.UriComponents uri, UrlResolverProperties.UrlResolverConfiguration config, BiFunction<String, String, Optional<T>> readByIdentifierAndIdentifierType) -
getPrefixMatch
protected <T> Optional<T> getPrefixMatch(org.springframework.web.util.UriComponents uri, UrlResolverProperties.UrlResolverConfiguration config, BiFunction<String, String, Optional<T>> readByIdentifierAndIdentifierType) -
getContextPathMatch
protected <T> Optional<T> getContextPathMatch(org.springframework.web.util.UriComponents uri, UrlResolverProperties.UrlResolverConfiguration config, BiFunction<String, String, Optional<T>> readByIdentifierAndIdentifierType) - Since:
- 1.8.6
-
isSchemeNotMatching
protected boolean isSchemeNotMatching(org.springframework.web.util.UriComponents uri, UrlResolverProperties.UrlResolverConfiguration config) -
isPortNotMatching
protected boolean isPortNotMatching(org.springframework.web.util.UriComponents uri, UrlResolverProperties.UrlResolverConfiguration config) -
isEmptyPort
-
isPathNotMatching
protected boolean isPathNotMatching(org.springframework.web.util.UriComponents uri, UrlResolverProperties.UrlResolverConfiguration config) -
isDomainNotMatching
protected boolean isDomainNotMatching(org.springframework.web.util.UriComponents uri, UrlResolverProperties.UrlResolverConfiguration config) -
isPrefixNotMatching
protected boolean isPrefixNotMatching(org.springframework.web.util.UriComponents uri, UrlResolverProperties.UrlResolverConfiguration config) -
trimPrefix
-
getDomainPrefix
-
getApplicationService
-
getTenantService
-
getProps
-