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
ConstructorDescriptionDefaultTenantResolver
(ApplicationService<Application> applicationService, TenantService<Tenant> tenantService, UrlResolverProperties props) -
Method Summary
Modifier and TypeMethodDescriptionconvertLocaleListToCurrencyList
(List<Locale> locales) protected org.springframework.web.util.UriComponents
convertUrlToUri
(String url) protected Optional<Application>
getApplicationForUri
(org.springframework.web.util.UriComponents uri) protected ApplicationService<Application>
protected <T> Optional<T>
getDomainMatch
(org.springframework.web.util.UriComponents uri, UrlResolverProperties.UrlResolverConfiguration config, BiFunction<String, String, Optional<T>> readByIdentifierAndIdentifierType) protected String
getDomainPrefix
(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 UrlResolverProperties
getProps()
getTenantForUri
(org.springframework.web.util.UriComponents uri) protected TenantService<Tenant>
protected boolean
isDomainNotMatching
(org.springframework.web.util.UriComponents uri, UrlResolverProperties.UrlResolverConfiguration config) protected boolean
isEmptyPort
(String port) protected boolean
isPathNotMatching
(org.springframework.web.util.UriComponents uri, UrlResolverProperties.UrlResolverConfiguration config) protected boolean
isPortNotMatching
(org.springframework.web.util.UriComponents uri, UrlResolverProperties.UrlResolverConfiguration config) protected boolean
isPrefixNotMatching
(org.springframework.web.util.UriComponents uri, UrlResolverProperties.UrlResolverConfiguration config) protected boolean
isSchemeNotMatching
(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 String
trimPrefix
(String host, String prefix) protected void
updateAllowedCurrencies
(Application application) protected void
updateAllowedCurrencies
(Tenant tenant) protected void
updateDefaultCurrency
(Application application) protected void
updateDefaultCurrency
(Tenant tenant)
-
Constructor Details
-
DefaultTenantResolver
public DefaultTenantResolver(ApplicationService<Application> applicationService, TenantService<Tenant> tenantService, UrlResolverProperties props)
-
-
Method Details
-
resolveApplication
Description copied from interface:TenantResolver
Resolves the application that matches the provided URL, or empty.- Specified by:
resolveApplication
in interfaceTenantResolver
- Parameters:
url
- the url to match to an Application- Returns:
- an optional application
-
resolveApplicationByURL
Description copied from interface:TenantResolver
Resolves the application that matches the provided URL, or empty.- Specified by:
resolveApplicationByURL
in interfaceTenantResolver
- Parameters:
url
- the url to match to an Application- Returns:
- an optional application
-
resolveApplicationById
Description copied from interface:TenantResolver
Resolves the application that matches the provided ID.- Specified by:
resolveApplicationById
in interfaceTenantResolver
- Parameters:
id
- the ID of the application- Returns:
- an optional application
-
resolveApplicationByToken
Description copied from interface:TenantResolver
Resolves the application that matches the provided token.- Specified by:
resolveApplicationByToken
in interfaceTenantResolver
- Parameters:
token
- the token of the application- Returns:
- an optional application
-
resolveAdminTenant
Description copied from interface:TenantResolver
Resolves the tenant for the admin that matches the provided URL, or empty.- Specified by:
resolveAdminTenant
in 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) -
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
-