com.ibm.commerce.foundation.rest.util
Class StoreConfigurationHelper
- java.lang.Object
-
- com.ibm.commerce.foundation.rest.util.StoreConfigurationHelper
-
public class StoreConfigurationHelper extends java.lang.Object
Utility class that provides store configuration information.
-
-
Field Summary
Fields Modifier and Type Field and Description static java.lang.String[]
ADDITIONAL_BUSINESS_CONTEXT_PARAMS
Additional parameters that are supported in business context.static java.lang.String
AUTHORING
Authoring.static java.lang.String
BUSINESS_CONTEXT
The business context.static java.lang.String
CATALOG_ID
The catalog Id.static java.lang.String
CONTENT_PERSONALIZATION
The content personalization Id.static java.lang.String
CURRENCY
The currency.static java.lang.String
DEFAULT_ACCESS_PROFILE
The default access profile, used when an access profile is not specified using theaccessProfile
query parameter.static java.lang.String
DEFAULT_CATALOG_CONFIG_GROUP_NAME
The name of the configuration groups in wc-component.xml which contains the mapping of store id and default catalog id for REST services.static java.lang.String
FIND_BY_ALL_XPATH
The XPATH expression, used to retrieve the Configuration by Allstatic java.lang.String
FIND_BY_IDENTIFIER_XPATH
The XPATH expression, used to retrieve the Configuration by Identifier.static java.lang.String
FIND_BY_STORE_ID_XPATH
The XPATH expression, used to retrieve the OnlineStore by store ID.static java.lang.String
FORMAT_ATOM
The response format value for Atom feeds.static java.lang.String
FORMAT_JSON
The response format value for JSON.static java.lang.String
IS_SECURE_KEY
The key used to store is request in Secure mode or not.static java.lang.String
LANGUAGE_ID
The language Id.static java.lang.String
LOCALE
The locale.static java.lang.String
PARTIAL_AUTHENTICATION
Business context flag indicating if partial authentication is used.static java.lang.String
PREVIEW
Preview.static java.lang.String
PREVIEW_TOKEN
The preview tokenstatic java.lang.String
PREVIEW_TOKEN_GEN_REQUEST
The preview token generation requeststatic java.lang.String
STORE_ID
The store Id.static java.lang.String
STORE_NAME
The store name.static java.lang.String
WORKSPACE_NAME
The workspace name.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static BusinessContextType
buildBusinessContext(java.util.Map<java.lang.String,java.lang.String> businessContextNVP)
This method builds aBusinessContextType<
from the provided map.static java.lang.String
getCatalogId(java.lang.String storeId)
This method returns the master catalogId of the specified store Id.static commonj.sdo.DataObject
getConfiguration(BusinessContextType businessContext, javax.security.auth.callback.CallbackHandler callbackHandler, java.lang.String expression, java.lang.String accessProfile)
This method retrieves the infrastructure details for the specified expression.static java.lang.String
getDefaultCatalogId(java.lang.String storeId)
This method returns the default catalogId of the specified store Id.static java.lang.String
getDefaultCurrency(java.util.ArrayList<java.lang.String> configuration)
This method gets the default store currency.static java.lang.String
getDefaultLanguageId(java.util.ArrayList<java.lang.String[]> configuration)
This method gets the default store languageId.static java.lang.String
getDefaultLocale(java.util.ArrayList<java.lang.String[]> configuration)
This method gets the default store locale.static java.lang.String
getLanguageForLocale(java.lang.String locale, java.util.ArrayList<java.lang.String[]> configuration)
This method gets the languageId that corresponds to the give locale.static java.lang.String
getLocaleForLanguage(java.lang.String languageId, java.util.ArrayList<java.lang.String[]> configuration)
This method gets the locale that corresponds to the give languageId.static java.util.List<java.lang.Integer>
getRelatedStoreIds(java.lang.Integer storeId)
This method gets the related stores'Id for the store with the provided id.static java.lang.String
getRequestLocale(javax.ws.rs.core.HttpHeaders headers)
This method gets the request locale from the HTTP headers.static javax.ws.rs.core.MediaType
getResponseFormat(java.lang.String responseFormat, javax.ws.rs.core.HttpHeaders headers)
This method gets the response format for the request.static java.util.Map<java.lang.String,java.lang.String>
getStoreConfiguration(java.lang.String storeId)
This method populates common store information for the specified store.static java.util.ArrayList<java.lang.String>
getStoreCurrencyConfiguration(java.lang.String storeId)
This method populates the store currency configuration for the specified store.static java.util.ArrayList<java.lang.String[]>
getStoreLanguageConfiguration(java.lang.String storeId)
This method populates the store language configuration for the specified store.static java.lang.String
getStoreName(java.lang.Integer storeId)
This method gets the store name by store id.static boolean
isCurrencySupported(java.lang.String currency, java.util.ArrayList<java.lang.String> configuration)
This method returns if the currency given is supported or not.static boolean
isLanguageSupported(java.lang.String languageId, java.util.ArrayList<java.lang.String[]> configuration)
This method returns if the language given is supported or not.static boolean
isLocaleSupported(java.lang.String locale, java.util.ArrayList<java.lang.String[]> configuration)
This method returns if the locale given is supported or not.
-
-
-
Field Detail
-
STORE_ID
public static final java.lang.String STORE_ID
The store Id.- See Also:
- Constant Field Values
-
STORE_NAME
public static final java.lang.String STORE_NAME
The store name.- See Also:
- Constant Field Values
-
LOCALE
public static final java.lang.String LOCALE
The locale.- See Also:
- Constant Field Values
-
LANGUAGE_ID
public static final java.lang.String LANGUAGE_ID
The language Id.- See Also:
- Constant Field Values
-
CURRENCY
public static final java.lang.String CURRENCY
The currency.- See Also:
- Constant Field Values
-
CATALOG_ID
public static final java.lang.String CATALOG_ID
The catalog Id.- See Also:
- Constant Field Values
-
PREVIEW_TOKEN
public static final java.lang.String PREVIEW_TOKEN
The preview token- See Also:
- Constant Field Values
-
PREVIEW_TOKEN_GEN_REQUEST
public static final java.lang.String PREVIEW_TOKEN_GEN_REQUEST
The preview token generation request- See Also:
- Constant Field Values
-
BUSINESS_CONTEXT
public static final java.lang.String BUSINESS_CONTEXT
The business context.- See Also:
- Constant Field Values
-
CONTENT_PERSONALIZATION
public static final java.lang.String CONTENT_PERSONALIZATION
The content personalization Id.- See Also:
- Constant Field Values
-
WORKSPACE_NAME
public static final java.lang.String WORKSPACE_NAME
The workspace name.- See Also:
- Constant Field Values
-
AUTHORING
public static final java.lang.String AUTHORING
Authoring.- See Also:
- Constant Field Values
-
PREVIEW
public static final java.lang.String PREVIEW
Preview.- See Also:
- Constant Field Values
-
PARTIAL_AUTHENTICATION
public static final java.lang.String PARTIAL_AUTHENTICATION
Business context flag indicating if partial authentication is used.- See Also:
- Constant Field Values
-
FORMAT_ATOM
public static final java.lang.String FORMAT_ATOM
The response format value for Atom feeds. Value is "atom".- See Also:
- Constant Field Values
-
IS_SECURE_KEY
public static final java.lang.String IS_SECURE_KEY
The key used to store is request in Secure mode or not.- See Also:
- Constant Field Values
-
FORMAT_JSON
public static final java.lang.String FORMAT_JSON
The response format value for JSON. Value is "json".- See Also:
- Constant Field Values
-
DEFAULT_CATALOG_CONFIG_GROUP_NAME
public static final java.lang.String DEFAULT_CATALOG_CONFIG_GROUP_NAME
The name of the configuration groups in wc-component.xml which contains the mapping of store id and default catalog id for REST services.- See Also:
- Constant Field Values
-
ADDITIONAL_BUSINESS_CONTEXT_PARAMS
public static final java.lang.String[] ADDITIONAL_BUSINESS_CONTEXT_PARAMS
Additional parameters that are supported in business context.
-
DEFAULT_ACCESS_PROFILE
public static final java.lang.String DEFAULT_ACCESS_PROFILE
The default access profile, used when an access profile is not specified using theaccessProfile
query parameter.- See Also:
- Constant Field Values
-
FIND_BY_IDENTIFIER_XPATH
public static final java.lang.String FIND_BY_IDENTIFIER_XPATH
The XPATH expression, used to retrieve the Configuration by Identifier.- See Also:
- Constant Field Values
-
FIND_BY_STORE_ID_XPATH
public static final java.lang.String FIND_BY_STORE_ID_XPATH
The XPATH expression, used to retrieve the OnlineStore by store ID.- See Also:
- Constant Field Values
-
FIND_BY_ALL_XPATH
public static final java.lang.String FIND_BY_ALL_XPATH
The XPATH expression, used to retrieve the Configuration by All- See Also:
- Constant Field Values
-
-
Method Detail
-
getStoreConfiguration
public static java.util.Map<java.lang.String,java.lang.String> getStoreConfiguration(java.lang.String storeId) throws AbstractBusinessObjectDocumentException
This method populates common store information for the specified store. For example, master catalog Id, webserver hostname, etc.- Parameters:
storeId
- the storeId to load configuration information for.- Returns:
- a map of store configuration information.
- Throws:
AbstractBusinessObjectDocumentException
- Raised when there is an exception.
-
getStoreName
public static java.lang.String getStoreName(java.lang.Integer storeId)
This method gets the store name by store id.- Parameters:
storeId
- the store id.- Returns:
- the store name.
-
getStoreLanguageConfiguration
public static java.util.ArrayList<java.lang.String[]> getStoreLanguageConfiguration(java.lang.String storeId) throws AbstractBusinessObjectDocumentException
This method populates the store language configuration for the specified store. See configuration noun.- Parameters:
storeId
- the storeId to load configuration information for.- Returns:
- an ArrayList of store language configuration information.
- Throws:
AbstractBusinessObjectDocumentException
- Raised when there is an exception.
-
getStoreCurrencyConfiguration
public static java.util.ArrayList<java.lang.String> getStoreCurrencyConfiguration(java.lang.String storeId) throws AbstractBusinessObjectDocumentException
This method populates the store currency configuration for the specified store. See configuration noun.- Parameters:
storeId
- the storeId to load configuration information for.- Returns:
- an ArrayList of store currency configuration information.
- Throws:
AbstractBusinessObjectDocumentException
- Raised when there is an exception.
-
buildBusinessContext
public static BusinessContextType buildBusinessContext(java.util.Map<java.lang.String,java.lang.String> businessContextNVP)
This method builds aBusinessContextType<
from the provided map.- Parameters:
businessContextNVP
- a map of data to add to the business context.- Returns:
- the
BusinessContextType
populated with the provided map.
-
getCatalogId
public static java.lang.String getCatalogId(java.lang.String storeId) throws AbstractBusinessObjectDocumentException
This method returns the master catalogId of the specified store Id.- Parameters:
storeId
- the storeId- Returns:
- the master catalogId.
- Throws:
AbstractBusinessObjectDocumentException
- Raised when there is an exception.
-
getDefaultCatalogId
public static java.lang.String getDefaultCatalogId(java.lang.String storeId) throws java.lang.Exception
This method returns the default catalogId of the specified store Id. This service should only used by REST service. If default catalog is defined for a store in catalog wc-component.xml file, the id of this default catalog will be returned. Otherwise, the default catalog defined in STOREDEFCAT table for this store is returned. If there is no default catalog defined for this store in STOREDEFCAT table, master catalog id will be returned.- Parameters:
storeId
- the store id- Returns:
- the default catalog id.
- Throws:
java.lang.Exception
- Exception is thrown when there is problem to get the default catalog id.
-
getResponseFormat
public static javax.ws.rs.core.MediaType getResponseFormat(java.lang.String responseFormat, javax.ws.rs.core.HttpHeaders headers)
This method gets the response format for the request. If theresponseFormat
parameter is null, the response format from the HTTP headers is used. If the HTTP headers do not contain a response format, a default of xml is used.- Parameters:
responseFormat
- The response format from the URL.headers
- The request HTTP headers.- Returns:
- the response format.
-
isLocaleSupported
public static boolean isLocaleSupported(java.lang.String locale, java.util.ArrayList<java.lang.String[]> configuration)
This method returns if the locale given is supported or not. The comparison is case-sensitive.- Parameters:
locale
- the localeconfiguration
- the store language configuration- Returns:
- true if the locale is supported, false otherwise.
-
getDefaultLocale
public static java.lang.String getDefaultLocale(java.util.ArrayList<java.lang.String[]> configuration)
This method gets the default store locale.- Parameters:
configuration
- the store language configuration- Returns:
- the default store locale.
-
getLocaleForLanguage
public static java.lang.String getLocaleForLanguage(java.lang.String languageId, java.util.ArrayList<java.lang.String[]> configuration)
This method gets the locale that corresponds to the give languageId.- Parameters:
languageId
- the languageIdconfiguration
- the store language configuration- Returns:
- the locale that corresponds to the languageId. Null if the languageId is not supported.
-
getLanguageForLocale
public static java.lang.String getLanguageForLocale(java.lang.String locale, java.util.ArrayList<java.lang.String[]> configuration)
This method gets the languageId that corresponds to the give locale.- Parameters:
locale
- the localeconfiguration
- the store language configuration- Returns:
- the languageId that corresponds to the locale. Null if the locale is not supported.
-
isLanguageSupported
public static boolean isLanguageSupported(java.lang.String languageId, java.util.ArrayList<java.lang.String[]> configuration)
This method returns if the language given is supported or not.- Parameters:
languageId
- the languageIdconfiguration
- the store language configuration- Returns:
- true if the language is supported, false otherwise.
-
getDefaultLanguageId
public static java.lang.String getDefaultLanguageId(java.util.ArrayList<java.lang.String[]> configuration)
This method gets the default store languageId.- Parameters:
configuration
- the store language configuration- Returns:
- the default store languageId.
-
isCurrencySupported
public static boolean isCurrencySupported(java.lang.String currency, java.util.ArrayList<java.lang.String> configuration)
This method returns if the currency given is supported or not.- Parameters:
currency
- the currencyconfiguration
- the store currency configuration- Returns:
- true if the currency is supported, false otherwise.
-
getDefaultCurrency
public static java.lang.String getDefaultCurrency(java.util.ArrayList<java.lang.String> configuration)
This method gets the default store currency.- Parameters:
configuration
- the store currency configuration- Returns:
- the default store currency.
-
getRequestLocale
public static java.lang.String getRequestLocale(javax.ws.rs.core.HttpHeaders headers)
This method gets the request locale from the HTTP headers. If the locale from the HTTP headers is null, the application server default locale is returned.- Parameters:
headers
- the request HTTP headers.- Returns:
- the request locale.
-
getRelatedStoreIds
public static java.util.List<java.lang.Integer> getRelatedStoreIds(java.lang.Integer storeId)
This method gets the related stores'Id for the store with the provided id.- Parameters:
storeId
- the ID of the online store.- Returns:
- the list of the related stores's Id for the provided storeId, the first item is the ID of the online store itself, the last item is the site level ID.
-
getConfiguration
public static commonj.sdo.DataObject getConfiguration(BusinessContextType businessContext, javax.security.auth.callback.CallbackHandler callbackHandler, java.lang.String expression, java.lang.String accessProfile) throws ConfigurationException
This method retrieves the infrastructure details for the specified expression.- Parameters:
businessContext
- the business context.callbackHandler
- the callback handler.expression
- the XPath expression.accessProfile
- the specified access profile.- Returns:
- the data object for the infrastructure.
- Throws:
ConfigurationException
- the infrastructure exception
-
-