Package de.hybris.platform.jalo
Class JaloSession
- java.lang.Object
-
- de.hybris.platform.jalo.AbstractJaloSession
-
- de.hybris.platform.jalo.JaloSession
-
- All Implemented Interfaces:
java.io.Serializable
- Direct Known Subclasses:
CommerceJaloSession,LDAPJaloSession,SessionTest.MySession
public class JaloSession extends AbstractJaloSession
The JaloSession is the central class for storing all session informations. It is used for- getting Managers
- getting/setting SessionContext objects
- posting events and registering EventListeners
- identifying items by their PKs.
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceJaloSession.LoginPropertiesContains login property names.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringCARTThe session attribute key for 'cart'.static java.lang.StringCART_TYPEstatic SessionContextCTX_NO_PREFTCH_LANGUAGESstatic java.lang.StringHYBRIS_ASSERT_INTERNALSstatic java.lang.StringIS_HMC_SESSIONstatic java.lang.StringPREFETCH_LANGUAGESstatic java.lang.StringREMOVE_CART_ON_CLOSEstatic java.lang.StringSESSION_TIMEOUT
-
Constructor Summary
Constructors Constructor Description JaloSession()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidactivate()Set the given JaloSession as the active session for the current thread.protected voidaddLocalSessionContext(SessionContext localCtx)voidappendSavedCart(Cart appendCart)Appends the entries from the saved cart to the session cart.static booleanassureSessionNotStale(JaloSession session)protected voidcheckSessionValidity()returns false if session is already closed()protected voidcleanup()voidclose()Closes this session.intcompareTo(java.lang.Object object)Implements item comparison by PK.protected CartcreateCart()Used by getCart() to create a new cart.SessionContextcreateLocalSessionContext()creates a new session context which hides this session's current context within the current thread until it is disabled viaremoveLocalSessionContext().SessionContextcreateLocalSessionContext(SessionContext original)JaloPropertyContainercreatePropertyContainer()Create a new property container that can be used for mass property updates.SearchContextcreateSearchContext()Returns a SearchContext object which is used for Search operations.SessionContextcreateSessionContext()Returns a SessionContext which is filled with the current session settings but is NOT bound to the session.protected SessionContextcreateSessionContext(SessionContext original)Creates a newSessionContextinstance setting given context as original.protected java.lang.StringcreateSessionID()creates a session ID for a newly created session.static voiddeactivate()remove the active session from the current thread.protected CartdoCreateCart(ComposedType cartType, User user, Currency curr, java.util.Date date, boolean isNet)booleanequals(java.lang.Object object)protected UserfindSessionUser(ComposedType userType, java.lang.String login)protected ComposedTypefindSessionUserType(java.lang.String sessionTypeString)java.lang.StringgenerateLoginTokenCookieValue()Generates a value entry for a CookieBasedLoginToken instance, which will be used by some web apps (like printcockpit, hmc, ...) for an 'auto' login processjava.lang.StringgenerateLoginTokenCookieValue(java.lang.String iso)Generates a value entry for a CookieBasedLoginToken instance, which will be used by some web apps (like printcockpit, hmc, ...) for an 'auto' login processAccessManagergetAccessManager()returns the AccessManager.protected CartgetAttachedCart()java.lang.ObjectgetAttribute(java.lang.String name)Returns the value of the attribute with the specified name from the attribute map of the current session context.java.util.EnumerationgetAttributeNames()Returns anEnumerationofStringobjects containing the names of all the objects bound to this session.java.util.MapgetAttributes()Returns the attribute map of the session context.C2LManagergetC2LManager()returns the C2LManager.CartgetCart()Returns the cart which is currently associated with this session.protected ComposedTypegetCartType()Provides composed type for newly created cart.longgetCreationTime()static JaloSessiongetCurrentSession()Returns the active session for the current thread and tenantstatic JaloSessiongetCurrentSession(Tenant tenant)protected intgetDefaultSessionTimeout()returns the default session timeout in seconds which will be assigned to a new session if it is created The default implementation returns the value of the "default.session.timeout" configuration parameter or '86400' if not set (that is 1 day).EnumerationManagergetEnumerationManager()return the enumeration managerExtensionManagergetExtensionManager()returns the ExtensionManger.FlexibleSearchgetFlexibleSearch()returns the FlexibleSearch.javax.servlet.http.HttpSessiongetHttpSession()Deprecated.since 5.5.1 session management was changed and this method always returns nulljava.lang.StringgetHttpSessionId()protected CurrencygetInitialSessionCurrency(User user)protected LanguagegetInitialSessionLanguage(User user)<T extends Item>
TgetItem(PK pk)returns the item with the given PK.<T extends Item>
TgetItem(java.lang.String pk)Deprecated.since ages - please usegetItem(PK)withPK.parse(String)java.util.Collection<? extends Item>getItems(SessionContext ctx, java.util.Collection<PK> pks)Returns a collection of items for a given collection of PKs.java.util.Collection<? extends Item>getItems(SessionContext ctx, java.util.Collection<PK> pks, boolean ignoreMissingItems)Returns a collection of items for a given collection of PKs.java.util.Collection<? extends Item>getItems(SessionContext ctx, java.util.Collection<PK> pks, boolean ignoreMissingItems, boolean returnMissingAsNull)Returns a collection of items for a given collection of PKs.java.util.Collection<? extends Item>getItems(java.util.Collection<PK> pks)Returns a collection of items for a given collection of PKs.longgetLastAccessed()LinkManagergetLinkManager()returns the LinkManager.protected SessionContextgetLocalSessionContext()java.util.MapgetLoginProperties()returns the properties that was used to create this session.protected LoginTokengetLoginToken(java.util.Map props)MediaManagergetMediaManager()returns the MediaManager.MetaInformationManagergetMetaInformationManager()returns the MetaInformationManager.NumberSeriesManagergetNumberSeriesManager()returns the NumberSeriesManager.OrderManagergetOrderManager()returns the OrderManager.PriceFactorygetPriceFactory()ProductManagergetProductManager()returns the ProductManager.SessionContextgetSessionContext()Returns the SessionContext currently bound to this session.java.lang.StringgetSessionID()Returns the session ID.<T extends Tenant>
TgetTenant()intgetTimeout()Deprecated.since 5.5.1 session management was changed and this method always return -1TypeManagergetTypeManager()returns the TypeManager.UsergetUser()Returns the user which is currently associated with this session.UserManagergetUserManager()returns the UserManager.booleanhasCart()static booleanhasCurrentSession()Helper method for testing if the current thread has an active session.static booleanhasCurrentSession(Tenant tenant)inthashCode()Returns the hashcode of this JaloSessionprotected voidinit()Overwrite this class for special initialization logic.protected voidinitSessionContext(java.util.Map props)protected UserinitUser(java.util.Map props, boolean isDefaultAnonymousSession)static JaloSessioninternalGetCurrentSession()Returns the active session for the current thread.protected booleanisAnonymousAndAnonymousLoginIsDisabled(java.lang.String login)Tells whether this is the anonymous account and anonymous login is disallowed ( using thelogin.anonymous.always.disabledconfiguration parameter ).booleanisClosed()returns true if this session is closed.protected booleanisDefaultAnonymous(java.util.Map props)booleanisExpired()Deprecated.since 5.5.1 session management was changed and this method always return falseprotected booleanisNotAnonymousOrAnonymousLoginIsAllowed(java.lang.String login)Tells whether this is not anonymous account or anonymous login is allowed by settinglogin.anonymous.always.disabledconfiguration parameter tofalse.protected booleanisRemoveCartOnSessionClose()static <T extends Item>
TlookupItem(PK pk)Same asgetItem(PK)but without actually requiring a session instance.static <T extends Item>
TlookupItem(Tenant tenant, PK pk)Same aslookupItem(PK)with the ability to pass the (required) tenant manually.static java.util.Collection<? extends Item>lookupItems(Tenant tenant, SessionContext ctx, java.util.Collection<PK> pks, boolean ignoreMissingItems, boolean returnMissingAsNull)static java.util.Collection<? extends Item>lookupItems(SessionContext ctx, java.util.Collection<PK> pks)Same asgetItems(SessionContext, Collection)but without requiring a jalo session instance.static java.util.Collection<? extends Item>lookupItems(SessionContext ctx, java.util.Collection<PK> pks, boolean ignoreMissingItems)Same asgetItems(SessionContext, Collection, boolean)but without requiring a jalo session instance.static java.util.Collection<? extends Item>lookupItems(SessionContext ctx, java.util.Collection<PK> pks, boolean ignoreMissingItems, boolean returnMissingAsNull)Same asgetItems(SessionContext, Collection, boolean, boolean)but without requiring a jalo session instance.protected voidnotifyExtensionsBeforeSessionClose()protected UserperformLogin(LoginToken token, java.util.Map loginProperties)performs login for a given login token and additionally params.protected UserperformLogin(java.lang.String login, java.lang.String password, java.util.Map loginProperties)performs login for a given login, password and additionally params.protected voidremoveAllLocalSessionContexts()java.lang.ObjectremoveAttribute(java.lang.String name)Removes the specified attribute from the attribute map of the current session context.voidremoveCart()Removes a cart from the current session and database, if theItem.remove()fails it is always clearing the internal reference.voidremoveLocalSessionContext()removes the (thread)local session context associated with this session so that the previous session context is visible again.voidrestoreSavedCart(Cart savedCart)Restores all entries from a saved cart to the session cart, thereby removes currently existing entries.SearchResultsearch(GenericQuery query)SearchResultsearch(GenericQuery query, SearchContext ctx)Initiates a search with the givenGenericQueryandSearchContext.SearchResultsearch(GenericQuery genericQuery, Principal principal, SearchContext searchCtx)Initiates a search with the givenGenericQueryandSearchContext.protected voidsetAttachedCart(Cart cart)java.lang.ObjectsetAttribute(java.lang.String name, java.lang.Object value)Sets a new value for the attribute with the specified name in the attribute map of the current session context.voidsetAttributes(java.util.Map attributes)Replaces multiple session attributes at once.voidsetCart(Cart cart)voidsetHttpSessionId(java.lang.String httpSessionId)Stores a http session id inside this session.protected voidsetLastAccessed(long accessed)protected voidsetLoginProperties(java.util.Map loginProperties)voidsetPriceFactory(PriceFactory factory)voidsetTimeout(int seconds)Deprecated.since 5.5.1 session management was changed and this method has no effectvoidsetTimeoutInMillis(long timeOutInMillis)Deprecated.since 5.5.1 session management was changed and this method has no effectvoidsetUser(User user)Changes the session user without any login processing.voidstoreLoginTokenCookie(javax.servlet.http.HttpServletResponse response)Generates and stores a CookieBasedLoginToken instance, for the current session user ('auto' login process)java.lang.StringtoString()returns a String representation which contains the SessionID and the UserID which is currently assigned to this Session.voidtouch()mark this session as used.voidtransfer(java.lang.String user, java.lang.String pwd)changes the session user including the full login process.voidtransfer(java.util.Map props)changes the session user including the full login process.voidtransfer(java.util.Map props, boolean activateUserLanguageAndCurrency)changes the session user including the full login process.
-
-
-
Field Detail
-
IS_HMC_SESSION
public static final java.lang.String IS_HMC_SESSION
- See Also:
- Constant Field Values
-
REMOVE_CART_ON_CLOSE
public static final java.lang.String REMOVE_CART_ON_CLOSE
- See Also:
- Constant Field Values
-
SESSION_TIMEOUT
public static final java.lang.String SESSION_TIMEOUT
- See Also:
- Constant Field Values
-
PREFETCH_LANGUAGES
public static final java.lang.String PREFETCH_LANGUAGES
- See Also:
- Constant Field Values
-
CART_TYPE
public static final java.lang.String CART_TYPE
- See Also:
- Constant Field Values
-
HYBRIS_ASSERT_INTERNALS
public static final java.lang.String HYBRIS_ASSERT_INTERNALS
- See Also:
- Constant Field Values
-
CART
public static final java.lang.String CART
The session attribute key for 'cart'. Use it ingetAttribute(String)for generically access the session cart.- See Also:
- Constant Field Values
-
CTX_NO_PREFTCH_LANGUAGES
public static final SessionContext CTX_NO_PREFTCH_LANGUAGES
-
-
Method Detail
-
getTenant
public <T extends Tenant> T getTenant()
-
assureSessionNotStale
public static boolean assureSessionNotStale(JaloSession session)
- Returns:
- false whenever given JaloSession has not exactly the same
tenantRestartMarkerwith the Tenant which is referenced by thisJaloSession.
-
init
protected void init()
Overwrite this class for special initialization logic.
-
createSessionContext
protected SessionContext createSessionContext(SessionContext original)
Creates a newSessionContextinstance setting given context as original. Overwrite this method to change implementation to use forSessionContext.- Since:
- 4.2
-
isDefaultAnonymous
protected boolean isDefaultAnonymous(java.util.Map props)
-
initSessionContext
protected void initSessionContext(java.util.Map props) throws JaloSecurityException- Throws:
JaloSecurityException
-
initUser
protected User initUser(java.util.Map props, boolean isDefaultAnonymousSession) throws JaloSecurityException
- Throws:
JaloSecurityException
-
createSessionID
protected java.lang.String createSessionID()
creates a session ID for a newly created session. currently this is done by creating a new PK of the session typecode. override this method to create own session ids.- Returns:
- the session id string
-
generateLoginTokenCookieValue
public java.lang.String generateLoginTokenCookieValue() throws EJBPasswordEncoderNotFoundExceptionGenerates a value entry for a CookieBasedLoginToken instance, which will be used by some web apps (like printcockpit, hmc, ...) for an 'auto' login process- Returns:
- the generated token. format: ${session.user PK}${session.language PK}${session.user.password} (sample: 11326704420716009013969790041776ee10c315eba2c75b403ea79136f5b38d)
- Throws:
EJBPasswordEncoderNotFoundException
-
generateLoginTokenCookieValue
public java.lang.String generateLoginTokenCookieValue(java.lang.String iso) throws EJBPasswordEncoderNotFoundExceptionGenerates a value entry for a CookieBasedLoginToken instance, which will be used by some web apps (like printcockpit, hmc, ...) for an 'auto' login process- Parameters:
iso- language- Returns:
- the generated token. format: ${session.user PK}${session.language PK}${session.user.password} (sample: 11326704420716009013969790041776ee10c315eba2c75b403ea79136f5b38d)
- Throws:
EJBPasswordEncoderNotFoundException
-
storeLoginTokenCookie
public void storeLoginTokenCookie(javax.servlet.http.HttpServletResponse response) throws EJBPasswordEncoderNotFoundExceptionGenerates and stores a CookieBasedLoginToken instance, for the current session user ('auto' login process)
-
performLogin
protected User performLogin(LoginToken token, java.util.Map loginProperties) throws JaloSecurityException
performs login for a given login token and additionally params. the method must return an existing user item - otherwise the session creation process will report an error. this method is called during session creation and session transfer. subclasses may override this method to implement own user search and/or login check behaviour.- Parameters:
token- login tokenloginProperties- logging properties ( seeJaloSession.LoginProperties)- Returns:
- the user which is associated with this newly created session
- Throws:
JaloSecurityException
-
performLogin
protected User performLogin(java.lang.String login, java.lang.String password, java.util.Map loginProperties) throws JaloSecurityException
performs login for a given login, password and additionally params. the method must return an existing user item - otherwise the session creation process will report an error. this method is called during session creation and session transfer. subclasses may override this method to implement own user search and/or login check behaviour.- Parameters:
login- user's loginpassword- user's passwordloginProperties- logging properties ( seeJaloSession.LoginProperties)- Returns:
- the user which is associated with this newly created session
- Throws:
JaloSecurityException
-
isAnonymousAndAnonymousLoginIsDisabled
protected boolean isAnonymousAndAnonymousLoginIsDisabled(java.lang.String login)
Tells whether this is the anonymous account and anonymous login is disallowed ( using thelogin.anonymous.always.disabledconfiguration parameter ).
-
isNotAnonymousOrAnonymousLoginIsAllowed
protected boolean isNotAnonymousOrAnonymousLoginIsAllowed(java.lang.String login)
Tells whether this is not anonymous account or anonymous login is allowed by settinglogin.anonymous.always.disabledconfiguration parameter tofalse.
-
findSessionUserType
protected ComposedType findSessionUserType(java.lang.String sessionTypeString) throws JaloInvalidParameterException
- Throws:
JaloInvalidParameterException
-
findSessionUser
protected User findSessionUser(ComposedType userType, java.lang.String login) throws JaloSecurityException, JaloInvalidParameterException
-
activate
public void activate()
Set the given JaloSession as the active session for the current thread. It is very important not to forget this. It can be not guaranteed that you can access objects that belongs to a 'not activated' session. This always ensures that you have no problems accessing the jalo objects. This method is automatically called e.g. when using WebSessionFunctions.getSession() to get a session.
-
deactivate
public static void deactivate()
remove the active session from the current thread.
-
setLastAccessed
protected void setLastAccessed(long accessed)
-
getCreationTime
public long getCreationTime()
- Returns:
- the creationTime
-
getLastAccessed
public long getLastAccessed()
- Returns:
- the lastAccessed
-
getCurrentSession
public static JaloSession getCurrentSession()
Returns the active session for the current thread and tenant If none is available, a new anonymous session will be created.- Returns:
- the current session
- Throws:
java.lang.IllegalStateException- in case no tenant is active
-
getCurrentSession
public static JaloSession getCurrentSession(Tenant tenant)
-
checkSessionValidity
protected void checkSessionValidity()
returns false if session is already closed()
-
touch
public void touch()
mark this session as used. The timeout is being reset. See also the setTimeout(), getTimeout() and isExpired()- Since:
- 3.0
-
getTimeout
@Deprecated public int getTimeout()
Deprecated.since 5.5.1 session management was changed and this method always return -1get the timeout in seconds. If the timeout is 0 or less the session will never expire.- Returns:
- the timeout in seconds
- Since:
- 3.0
-
setTimeout
@Deprecated public void setTimeout(int seconds)
Deprecated.since 5.5.1 session management was changed and this method has no effectset the timeout in seconds. If 0 or less is specified, the session will never expire.- Parameters:
seconds- the timeout in seconds- Since:
- 3.0
-
setTimeoutInMillis
@Deprecated public void setTimeoutInMillis(long timeOutInMillis)
Deprecated.since 5.5.1 session management was changed and this method has no effectSet the timeout in milliseconds! Same assetTimeout(int)but expects the timeout in milliseconds here! If 0 or less is specified, the session will never expire.- Parameters:
timeOutInMillis- the time out of the session in milli seconds- Since:
- 4.5
-
isExpired
@Deprecated public boolean isExpired()
Deprecated.since 5.5.1 session management was changed and this method always return falsechecks whether the current session is expired. if the timeout was set to 0 seconds or less, the session will never expire- Since:
- 3.0
-
getDefaultSessionTimeout
protected int getDefaultSessionTimeout()
returns the default session timeout in seconds which will be assigned to a new session if it is created The default implementation returns the value of the "default.session.timeout" configuration parameter or '86400' if not set (that is 1 day). this method can be overridden by subclasses.- Since:
- 3.0
-
internalGetCurrentSession
public static JaloSession internalGetCurrentSession()
Returns the active session for the current thread. If none is available NULL is returned- Returns:
- the JaloSession or null
-
hasCurrentSession
public static boolean hasCurrentSession()
Helper method for testing if the current thread has an active session. The advantage of calling this method instead of getCurrentSession() is that you do not have to catch an Exception.- Returns:
trueif the current thread has an active session (that is not already closed()), false otherwise
-
hasCurrentSession
public static boolean hasCurrentSession(Tenant tenant)
-
getUser
public User getUser()
Returns the user which is currently associated with this session.- Returns:
- the user which is currently associated with this session
-
setUser
public void setUser(User user)
Changes the session user without any login processing. Further the session cart is assigned to the new user.- Parameters:
user- the new user
-
transfer
public void transfer(java.util.Map props) throws JaloSecurityException, JaloInvalidParameterExceptionchanges the session user including the full login process. any settings made to this session are kept except that the session cart is assigned to the new session user. The default language and currency will not be set for the new user. Therefore usetransfer(Map props, boolean activateUserLanguageAndCurrency)with last parameter = true.- Parameters:
props- logging properties ( seeJaloSession.LoginProperties)- Throws:
JaloSecurityException- in case login process failedJaloInvalidParameterException- in case some provided parameter had an unexpected value
-
transfer
public void transfer(java.lang.String user, java.lang.String pwd) throws JaloSecurityExceptionchanges the session user including the full login process. any settings made to this session are kept except that the session cart is assigned to the new session user. The default language and currency will not be set for the new user. Therefore usetransfer(Map props, boolean activateUserLanguageAndCurrency)with last parameter = true.- Parameters:
user- the new userpwd- the password of the user- Throws:
JaloSecurityException- in case login process failed
-
transfer
public void transfer(java.util.Map props, boolean activateUserLanguageAndCurrency) throws JaloSecurityException, JaloInvalidParameterExceptionchanges the session user including the full login process. any settings made to this session are kept except that the session cart is assigned to the new session user. if specified the session language and session currency is changed to the values belonging to the new user ( seeGeneratedUser.getSessionLanguage()andGeneratedUser.getSessionCurrency()). Set the Boolean activateUserLanguageAndCurrency totrueif you want the new user to use his / her default language and currency. If set tofalse, the new user will have the language and currency used by the former user.- Parameters:
props- logging properties ( seeJaloSession.LoginProperties)activateUserLanguageAndCurrency- if true the session language and session currency are set to the values set at the new user- Throws:
JaloSecurityException- in case login process failedJaloInvalidParameterException- in case some provided parameter had an unexpected value
-
getLoginToken
protected LoginToken getLoginToken(java.util.Map props)
-
getCart
public Cart getCart()
Returns the cart which is currently associated with this session. if no cart is available at this time, a new one is created.- Returns:
- the cart which is currently associated with this session
-
getAttachedCart
protected Cart getAttachedCart()
-
setAttachedCart
protected void setAttachedCart(Cart cart)
-
createCart
protected Cart createCart()
Used by getCart() to create a new cart.- Returns:
- the new
Cart
-
getCartType
protected ComposedType getCartType()
Provides composed type for newly created cart. Fetches type from either session context (first) or configuration (second). If no type has been specified it returnsnull.
-
doCreateCart
protected Cart doCreateCart(ComposedType cartType, User user, Currency curr, java.util.Date date, boolean isNet)
-
hasCart
public boolean hasCart()
-
removeCart
public void removeCart()
Removes a cart from the current session and database, if theItem.remove()fails it is always clearing the internal reference.
-
setCart
public void setCart(Cart cart)
-
restoreSavedCart
public void restoreSavedCart(Cart savedCart)
Restores all entries from a saved cart to the session cart, thereby removes currently existing entries.- Parameters:
savedCart-
-
appendSavedCart
public void appendSavedCart(Cart appendCart)
Appends the entries from the saved cart to the session cart.- Parameters:
appendCart-
-
getLoginProperties
public java.util.Map getLoginProperties()
returns the properties that was used to create this session. When creating a session withJaloConnection.createSession()you have to specify a map with user informations. This method returns this 'login-information' map.- Returns:
- the properties that were used to create this session
-
setLoginProperties
protected void setLoginProperties(java.util.Map loginProperties)
-
setAttributes
public void setAttributes(java.util.Map attributes)
Replaces multiple session attributes at once. Please note that previously stored attributes are not removed if their keys are not included in the new map.- Parameters:
attributes- the attributes to store
-
getAttributes
public java.util.Map getAttributes()
Returns the attribute map of the session context.- Returns:
- the attribute map of the current session context
-
getAttribute
public java.lang.Object getAttribute(java.lang.String name)
Returns the value of the attribute with the specified name from the attribute map of the current session context.- Parameters:
name- of the attribute- Returns:
- the value of the attribute specified in the parameter name
-
setAttribute
public java.lang.Object setAttribute(java.lang.String name, java.lang.Object value)Sets a new value for the attribute with the specified name in the attribute map of the current session context.- Parameters:
name- of the attributevalue- the new value- Returns:
- the old value of the attribute specified in the parameter name
-
getAttributeNames
public java.util.Enumeration getAttributeNames()
Returns anEnumerationofStringobjects containing the names of all the objects bound to this session.- Returns:
- an
EnumerationofStringobjects containing the names of all the objects bound to this session.
-
removeAttribute
public java.lang.Object removeAttribute(java.lang.String name)
Removes the specified attribute from the attribute map of the current session context.- Parameters:
name- of the attribute, which should be removed- Returns:
- the value of the removed attribute
-
getAccessManager
public AccessManager getAccessManager()
returns the AccessManager.- Returns:
- the AccessManager object
-
getUserManager
public UserManager getUserManager()
returns the UserManager.- Returns:
- the UserManager object
-
getProductManager
public ProductManager getProductManager()
returns the ProductManager.- Returns:
- the ProductManager object
-
getNumberSeriesManager
public NumberSeriesManager getNumberSeriesManager()
returns the NumberSeriesManager.- Returns:
- the NumberSeriesManager object
-
getFlexibleSearch
public FlexibleSearch getFlexibleSearch()
returns the FlexibleSearch.- Returns:
- the FlexibleSearch object
-
getC2LManager
public C2LManager getC2LManager()
returns the C2LManager.- Returns:
- the C2LManager object
-
getMetaInformationManager
public MetaInformationManager getMetaInformationManager()
returns the MetaInformationManager.- Returns:
- the MetaInformationManager object
-
getMediaManager
public MediaManager getMediaManager()
returns the MediaManager.- Returns:
- the MediaManager object
-
getOrderManager
public OrderManager getOrderManager()
returns the OrderManager.- Returns:
- the OrderManager object
-
getLinkManager
public LinkManager getLinkManager()
returns the LinkManager.- Returns:
- the LinkManager object
-
getExtensionManager
public ExtensionManager getExtensionManager()
returns the ExtensionManger.- Returns:
- the ExtensionManager object
-
getTypeManager
public TypeManager getTypeManager()
returns the TypeManager.- Returns:
- the TypeManager object
-
getEnumerationManager
public EnumerationManager getEnumerationManager()
return the enumeration manager- Returns:
- the EnumerationManager object
-
getSessionContext
public SessionContext getSessionContext()
Returns the SessionContext currently bound to this session. All changes in this SessionContext will directly modify the session's context. You can use the following code fragment to change the session language:SessionContext ctx = jaloSession.getSessionContext(); ctx.setLanguage(xy);
.- Returns:
- the SessionContext object
-
getLocalSessionContext
protected SessionContext getLocalSessionContext()
-
addLocalSessionContext
protected void addLocalSessionContext(SessionContext localCtx)
-
createSessionContext
public SessionContext createSessionContext()
Returns a SessionContext which is filled with the current session settings but is NOT bound to the session. This means you can change the returned SessionContext object without reflecting these changes into the session.- Returns:
- the SessionContext object
-
createLocalSessionContext
public SessionContext createLocalSessionContext()
creates a new session context which hides this session's current context within the current thread until it is disabled viaremoveLocalSessionContext(). since createLocalSessionContext may be called multiple time the now visible context might be a local context too. please note that any changes made on this sessions context will not pass through to the original context and therefore will be lost after disabling the local context. the saves way to use local session context requires finally blocks:try { SessionContext myLocalCtx = JaloSession.getCurrentSession().createLocalSessionContext(); myLocalCtx.setAttribute("specialForThisThreadOnly", myValue); // do whatever in this context should be done } finally { JaloSession.getCurrentSession().removeLocalSessionContext(); }- Returns:
- the new (thread)local session context
-
createLocalSessionContext
public SessionContext createLocalSessionContext(SessionContext original)
-
removeLocalSessionContext
public void removeLocalSessionContext()
removes the (thread)local session context associated with this session so that the previous session context is visible again. sincecreateLocalSessionContext()may be called multiple time the now visible context might be a local context too.
-
removeAllLocalSessionContexts
protected void removeAllLocalSessionContexts()
-
createSearchContext
public SearchContext createSearchContext()
Returns a SearchContext object which is used for Search operations.- Returns:
- a SearchContext object
-
lookupItem
public static <T extends Item> T lookupItem(PK pk) throws JaloItemNotFoundException
Same asgetItem(PK)but without actually requiring a session instance.- Throws:
JaloItemNotFoundException
-
lookupItem
public static <T extends Item> T lookupItem(Tenant tenant, PK pk) throws JaloItemNotFoundException
Same aslookupItem(PK)with the ability to pass the (required) tenant manually.- Throws:
JaloItemNotFoundException
-
lookupItems
public static java.util.Collection<? extends Item> lookupItems(SessionContext ctx, java.util.Collection<PK> pks) throws JaloItemNotFoundException
Same asgetItems(SessionContext, Collection)but without requiring a jalo session instance.- Throws:
JaloItemNotFoundException
-
lookupItems
public static java.util.Collection<? extends Item> lookupItems(SessionContext ctx, java.util.Collection<PK> pks, boolean ignoreMissingItems) throws JaloItemNotFoundException
Same asgetItems(SessionContext, Collection, boolean)but without requiring a jalo session instance.- Throws:
JaloItemNotFoundException
-
lookupItems
public static java.util.Collection<? extends Item> lookupItems(SessionContext ctx, java.util.Collection<PK> pks, boolean ignoreMissingItems, boolean returnMissingAsNull) throws JaloItemNotFoundException
Same asgetItems(SessionContext, Collection, boolean, boolean)but without requiring a jalo session instance.- Throws:
JaloItemNotFoundException
-
lookupItems
public static java.util.Collection<? extends Item> lookupItems(Tenant tenant, SessionContext ctx, java.util.Collection<PK> pks, boolean ignoreMissingItems, boolean returnMissingAsNull) throws JaloItemNotFoundException
- Throws:
JaloItemNotFoundException
-
getItem
public <T extends Item> T getItem(PK pk) throws JaloItemNotFoundException
returns the item with the given PK.- Parameters:
pk- the primary key object of the item- Returns:
- the Item, if found
- Throws:
JaloItemNotFoundException- if the item could not be found in the system
-
getItem
@Deprecated public <T extends Item> T getItem(java.lang.String pk) throws JaloItemNotFoundException, java.lang.IllegalArgumentException
Deprecated.since ages - please usegetItem(PK)withPK.parse(String)returns the item with the given PK.- Parameters:
pk- the item primary key as string representation ( seePK.toString())- Returns:
- the item if found
- Throws:
JaloItemNotFoundException- in case no item can be foundjava.lang.IllegalArgumentException- in case the string is no valid PK representation
-
getItems
public java.util.Collection<? extends Item> getItems(java.util.Collection<PK> pks) throws JaloItemNotFoundException
Returns a collection of items for a given collection of PKs. Use this method for example, if you transfer PKs via GET/POST request from one JSP page to another and then want to 'reincarnate' the item.- Parameters:
pks- the primary key collection- Returns:
- a collection containing Item instances
- Throws:
JaloItemNotFoundException- if one item could not be found in the system
-
getItems
public java.util.Collection<? extends Item> getItems(SessionContext ctx, java.util.Collection<PK> pks) throws JaloItemNotFoundException
Returns a collection of items for a given collection of PKs. Use this method for example, if you transfer PKs via GET/POST request from one JSP page to another and then want to 'reincarnate' the item.- Parameters:
ctx- the session context to define advanced settings like data prefetchingpks- the primary key collection- Returns:
- a collection containing Item instances
- Throws:
JaloItemNotFoundException- if one item could not be found in the system
-
getItems
public java.util.Collection<? extends Item> getItems(SessionContext ctx, java.util.Collection<PK> pks, boolean ignoreMissingItems) throws JaloItemNotFoundException
Returns a collection of items for a given collection of PKs. Use this method for example, if you transfer PKs via GET/POST request from one JSP page to another and then want to 'reincarnate' the item.- Parameters:
ctx- the session context to define advanced settings like data pre-fetchingpks- the primary key collectionignoreMissingItems- if true invalid item PKs are simply ignored and omitted from the result collection- Returns:
- a collection containing Item instances
- Throws:
JaloItemNotFoundException- if one item could not be found in the system unless ignoreMissingItems is true
-
getItems
public java.util.Collection<? extends Item> getItems(SessionContext ctx, java.util.Collection<PK> pks, boolean ignoreMissingItems, boolean returnMissingAsNull) throws JaloItemNotFoundException
Returns a collection of items for a given collection of PKs. Use this method for example, if you transfer PKs via GET/POST request from one JSP page to another and then want to 'reincarnate' the item.- Parameters:
ctx- the session context to define advanced settings like data pre-fetchingpks- the primary key collectionignoreMissingItems- if true invalid item PKs are simply ignored and omitted from the result collectionreturnMissingAsNull- if true when ignoring missing items all non-existent PKs will be returned as NULL within the result collection - otherwise the missing PK is filtered completely- Returns:
- a collection containing Item instances
- Throws:
JaloItemNotFoundException- if one item could not be found in the system unless ignoreMissingItems is true
-
getSessionID
public java.lang.String getSessionID()
Returns the session ID. The session id is a generated unique string.- Returns:
- the session id
-
toString
public java.lang.String toString()
returns a String representation which contains the SessionID and the UserID which is currently assigned to this Session.- Overrides:
toStringin classjava.lang.Object- Returns:
- the string representation of this session
-
isClosed
public boolean isClosed()
returns true if this session is closed.- Returns:
- true if this session is closed.
-
close
public void close()
Closes this session. After closing a session is cannot be guaranteed that you can access items or manager belonging to this session. You should call this method if you do not need this session anymore, because all reserved resources will be freed.
-
cleanup
protected void cleanup()
-
isRemoveCartOnSessionClose
protected boolean isRemoveCartOnSessionClose()
-
createPropertyContainer
public JaloPropertyContainer createPropertyContainer()
Create a new property container that can be used for mass property updates.- Returns:
- the new property container
- See Also:
ExtensibleItem.setAllProperties(JaloPropertyContainer)
-
getHttpSession
@Deprecated public javax.servlet.http.HttpSession getHttpSession()
Deprecated.since 5.5.1 session management was changed and this method always returns nullreturns the HttpSession, which is currently associated to this jalo session. can be null. A HttpSession is automatically associated if this session is created via WebSessionFunctions.getSession(..)- Returns:
- the HttpSession
-
setHttpSessionId
public void setHttpSessionId(java.lang.String httpSessionId)
Stores a http session id inside this session.
-
getHttpSessionId
public java.lang.String getHttpSessionId()
-
search
public SearchResult search(GenericQuery query, SearchContext ctx)
Initiates a search with the givenGenericQueryandSearchContext.- Parameters:
query- A GenericQuery instance that specifies your search query.ctx- Besides standard evaluation ofSearchContext, following custom properties are considered valid:GenericSearchConstants.DONT_NEED_TOTAL-> default is true.- Returns:
- SearchResult
-
search
public SearchResult search(GenericQuery query)
-
setPriceFactory
public void setPriceFactory(PriceFactory factory)
-
getPriceFactory
public PriceFactory getPriceFactory()
-
search
public SearchResult search(GenericQuery genericQuery, Principal principal, SearchContext searchCtx)
Initiates a search with the givenGenericQueryandSearchContext.- Parameters:
genericQuery- A GenericQuery instance that specifies your search query.principal- APrincipalinstance for restriction evaluation.searchCtx- Besides standard evaluation ofSearchContext, following custom properties are considered valid:GenericSearchConstants.DONT_NEED_TOTAL-> default is true.- Returns:
- SearchResult
-
notifyExtensionsBeforeSessionClose
protected void notifyExtensionsBeforeSessionClose()
-
equals
public final boolean equals(java.lang.Object object)
- Overrides:
equalsin classjava.lang.Object
-
compareTo
public int compareTo(java.lang.Object object)
Implements item comparison by PK. Subclasses may override this.- Parameters:
object- which will be compared to this item.- Returns:
- the value 0 if the argument item pk is equal to this item pk; a value less than 0 if this item pk is lexicographically less than the argument item pk; and a value greater than 0 if this item pk is lexicographically greater than the argument item pk.
-
hashCode
public final int hashCode()
Returns the hashcode of this JaloSession The hashcode of an item is defined as the hashcode of its primary key object.- Overrides:
hashCodein classjava.lang.Object- Returns:
- the hashcode of this item.
-
-