Class PersistenceConfigurationLifecycleStrategyImpl
- java.lang.Object
-
- de.hybris.platform.sap.productconfig.services.strategies.lifecycle.impl.PersistenceConfigurationLifecycleStrategyImpl
-
- All Implemented Interfaces:
ConfigurationLifecycleStrategy
public class PersistenceConfigurationLifecycleStrategyImpl extends java.lang.Object implements ConfigurationLifecycleStrategy
-
-
Constructor Summary
Constructors Constructor Description PersistenceConfigurationLifecycleStrategyImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ConfigModelcreateConfigurationFromExternalSource(Configuration extConfig)Creates a configuration from the configuration in external format which can be provided from outside, e.g.ConfigModelcreateConfigurationFromExternalSource(KBKey kbKey, java.lang.String extConfig)Creates a configuration from an XML string containing the configuration in external format.ConfigModelcreateDefaultConfiguration(KBKey kbKey)Creates a default configuration for the required knowledge base.protected ConfigurationProvidergetConfigurationProvider()protected ModelServicegetModelService()protected ProductConfigurationPersistenceServicegetPersistenceService()protected java.lang.StringgetProductLinkedToProductConfiguration(ProductConfigurationModel configModel)protected ProviderFactorygetProviderFactory()protected SessionServicegetSessionService()protected UserServicegetUserService()protected booleanisAdminUser(UserModel currentUser)booleanisConfigForCurrentUser(java.lang.String configId)Checks whether the given configuration may be accessed by the current userbooleanisConfigKnown(java.lang.String configId)Checks whether the given configuration is persisted/known.
In case configuration was created by an external system, it may not be known, but may still be processed within hybris.protected booleanisProductLinkedToProductConfiguration(ProductConfigurationModel configModel)protected booleanisSameSession(ProductConfigurationModel productConfiguration)protected booleanisSameUser(ProductConfigurationModel productConfiguration, UserModel currentUser)protected voidpersistNewConfiguration(ConfigModel config)protected booleanpersistSessionId()voidreleaseExpiredSessions(java.lang.String userSessionId)Releases sessions identified by the provided ID.voidreleaseSession(java.lang.String configId)Releases the configuration sessions identified by the provided ID and all associated resources.protected voidreleaseSessionSafely(java.lang.String configId, java.lang.String currentVersion)protected voidremoveDuplicateProductLink(ProductConfigurationModel actualConfigModel)ConfigModelretrieveConfigurationFromVariant(java.lang.String baseProductCode, java.lang.String variantProductCode)Get configuration for the base product, initialized with given configuration of the variantConfigModelretrieveConfigurationModel(java.lang.String configId)Retrieve the current state of the configuration model for the requestedconfigId.ConfigModelretrieveConfigurationModel(java.lang.String configId, ConfigurationRetrievalOptions options)Retrieve the current state of the configuration model for the requestedconfigId.java.lang.StringretrieveExternalConfiguration(java.lang.String configId)Retrieve the current state of the configuration for the requestedconfigIdas an XML string containing the configuration in external format.voidsetModelService(ModelService modelService)voidsetPersistenceService(ProductConfigurationPersistenceService persistenceService)voidsetProviderFactory(ProviderFactory providerFactory)voidsetSessionService(SessionService sessionService)voidsetUserService(UserService userService)booleanupdateConfiguration(ConfigModel model)Checks the configuration model for changes since the last update and will send only the changes to the configuration engine, if any.protected voidupdateETag(java.lang.String newVersion, ConfigModel configModel, ProductConfigurationModel persistenceModel)protected voidupdateETagFromModel(ConfigModel configModel)voidupdateUserLinkToConfiguration(java.lang.String userSessionId)Updates ProductConfigurationModel, after user loged in.
-
-
-
Method Detail
-
createDefaultConfiguration
public ConfigModel createDefaultConfiguration(KBKey kbKey)
Description copied from interface:ConfigurationLifecycleStrategyCreates a default configuration for the required knowledge base. The knowledge base (KB) can be identified e.g. via the product code or via the KB name, version and logical system.- Specified by:
createDefaultConfigurationin interfaceConfigurationLifecycleStrategy- Parameters:
kbKey- Information needed to identify a knowledge base- Returns:
- The configurable product with default configuration
-
persistNewConfiguration
protected void persistNewConfiguration(ConfigModel config)
-
updateUserLinkToConfiguration
public void updateUserLinkToConfiguration(java.lang.String userSessionId)
Description copied from interface:ConfigurationLifecycleStrategyUpdates ProductConfigurationModel, after user loged in.- Specified by:
updateUserLinkToConfigurationin interfaceConfigurationLifecycleStrategy- Parameters:
userSessionId- user session Id
-
removeDuplicateProductLink
protected void removeDuplicateProductLink(ProductConfigurationModel actualConfigModel)
-
isProductLinkedToProductConfiguration
protected boolean isProductLinkedToProductConfiguration(ProductConfigurationModel configModel)
-
getProductLinkedToProductConfiguration
protected java.lang.String getProductLinkedToProductConfiguration(ProductConfigurationModel configModel)
-
releaseExpiredSessions
public void releaseExpiredSessions(java.lang.String userSessionId)
Description copied from interface:ConfigurationLifecycleStrategyReleases sessions identified by the provided ID. Accessing the session afterwards is not possible anymore.- Specified by:
releaseExpiredSessionsin interfaceConfigurationLifecycleStrategy- Parameters:
userSessionId- id of the user session
-
updateConfiguration
public boolean updateConfiguration(ConfigModel model) throws ConfigurationEngineException
Description copied from interface:ConfigurationLifecycleStrategyChecks the configuration model for changes since the last update and will send only the changes to the configuration engine, if any.- Specified by:
updateConfigurationin interfaceConfigurationLifecycleStrategy- Parameters:
model- Updated model- Returns:
true, only if it was necessary to send an updare to the configuration egnine- Throws:
ConfigurationEngineException
-
retrieveConfigurationModel
public ConfigModel retrieveConfigurationModel(java.lang.String configId) throws ConfigurationEngineException
Description copied from interface:ConfigurationLifecycleStrategyRetrieve the current state of the configuration model for the requestedconfigId.- Specified by:
retrieveConfigurationModelin interfaceConfigurationLifecycleStrategy- Parameters:
configId- Unique configuration ID- Returns:
- The actual configuration
- Throws:
ConfigurationEngineException- Service has failed, e.g. because session timed out
-
retrieveConfigurationModel
public ConfigModel retrieveConfigurationModel(java.lang.String configId, ConfigurationRetrievalOptions options) throws ConfigurationEngineException
Description copied from interface:ConfigurationLifecycleStrategyRetrieve the current state of the configuration model for the requestedconfigId.- Specified by:
retrieveConfigurationModelin interfaceConfigurationLifecycleStrategy- Parameters:
configId- Unique configuration IDoptions- options to consider while reading the configuration, such as additional/updated variant conditions for pricing- Returns:
- The actual configuration
- Throws:
ConfigurationEngineException- Service has failed, e.g. because session timed out
-
retrieveExternalConfiguration
public java.lang.String retrieveExternalConfiguration(java.lang.String configId) throws ConfigurationEngineExceptionDescription copied from interface:ConfigurationLifecycleStrategyRetrieve the current state of the configuration for the requestedconfigIdas an XML string containing the configuration in external format.- Specified by:
retrieveExternalConfigurationin interfaceConfigurationLifecycleStrategy- Parameters:
configId- Unique configuration ID- Returns:
- The actual configuration as XML string
- Throws:
ConfigurationEngineException- Service has failed, e.g. because session timed out
-
createConfigurationFromExternalSource
public ConfigModel createConfigurationFromExternalSource(Configuration extConfig)
Description copied from interface:ConfigurationLifecycleStrategyCreates a configuration from the configuration in external format which can be provided from outside, e.g. from the configuration prepared in the back end.
This API does _not_ force the KB related attributes to be existing. In case only the product ID is provided, a matching KB version is determined.- Specified by:
createConfigurationFromExternalSourcein interfaceConfigurationLifecycleStrategy- Parameters:
extConfig- External configuration in external format- Returns:
- Configuration model
-
createConfigurationFromExternalSource
public ConfigModel createConfigurationFromExternalSource(KBKey kbKey, java.lang.String extConfig)
Description copied from interface:ConfigurationLifecycleStrategyCreates a configuration from an XML string containing the configuration in external format.
This API requires the KB related attributes as part of the external configuration to be available, they are directly forwarded to the configuration engine.- Specified by:
createConfigurationFromExternalSourcein interfaceConfigurationLifecycleStrategy- Parameters:
kbKey- Information needed to create a knowledge baseextConfig- External configuration as XML string- Returns:
- Configuration model
-
releaseSession
public void releaseSession(java.lang.String configId)
Description copied from interface:ConfigurationLifecycleStrategyReleases the configuration sessions identified by the provided ID and all associated resources. Accessing the session afterwards is not possible anymore.- Specified by:
releaseSessionin interfaceConfigurationLifecycleStrategy- Parameters:
configId- id of the config session
-
releaseSessionSafely
protected void releaseSessionSafely(java.lang.String configId, java.lang.String currentVersion)
-
retrieveConfigurationFromVariant
public ConfigModel retrieveConfigurationFromVariant(java.lang.String baseProductCode, java.lang.String variantProductCode)
Description copied from interface:ConfigurationLifecycleStrategyGet configuration for the base product, initialized with given configuration of the variant- Specified by:
retrieveConfigurationFromVariantin interfaceConfigurationLifecycleStrategy- Returns:
- The pre-filled configuration model
-
isConfigForCurrentUser
public boolean isConfigForCurrentUser(java.lang.String configId)
Description copied from interface:ConfigurationLifecycleStrategyChecks whether the given configuration may be accessed by the current user- Specified by:
isConfigForCurrentUserin interfaceConfigurationLifecycleStrategy- Parameters:
configId- configuration id- Returns:
- true if configuration may be accessed by current user
-
isSameSession
protected boolean isSameSession(ProductConfigurationModel productConfiguration)
-
isSameUser
protected boolean isSameUser(ProductConfigurationModel productConfiguration, UserModel currentUser)
-
isAdminUser
protected boolean isAdminUser(UserModel currentUser)
-
updateETagFromModel
protected void updateETagFromModel(ConfigModel configModel)
-
updateETag
protected void updateETag(java.lang.String newVersion, ConfigModel configModel, ProductConfigurationModel persistenceModel)
-
getConfigurationProvider
protected ConfigurationProvider getConfigurationProvider()
-
getModelService
protected ModelService getModelService()
-
setModelService
public void setModelService(ModelService modelService)
-
getProviderFactory
protected ProviderFactory getProviderFactory()
-
setProviderFactory
public void setProviderFactory(ProviderFactory providerFactory)
-
getUserService
protected UserService getUserService()
-
setUserService
public void setUserService(UserService userService)
-
getSessionService
protected SessionService getSessionService()
-
setSessionService
public void setSessionService(SessionService sessionService)
-
getPersistenceService
protected ProductConfigurationPersistenceService getPersistenceService()
-
setPersistenceService
public void setPersistenceService(ProductConfigurationPersistenceService persistenceService)
-
persistSessionId
protected boolean persistSessionId()
-
isConfigKnown
public boolean isConfigKnown(java.lang.String configId)
Description copied from interface:ConfigurationLifecycleStrategyChecks whether the given configuration is persisted/known.
In case configuration was created by an external system, it may not be known, but may still be processed within hybris.- Specified by:
isConfigKnownin interfaceConfigurationLifecycleStrategy- Parameters:
configId- configuration id- Returns:
- true if configuration is persisted and known by hybris
-
-