Package de.hybris.platform.jalo
Class JaloSession
java.lang.Object
de.hybris.platform.jalo.AbstractJaloSession
de.hybris.platform.jalo.JaloSession
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
CommerceJaloSession,LDAPJaloSession,SessionTest.MySession
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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceContains login property names. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidactivate()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 voidreturns false if session is already closed()protected voidcleanup()voidclose()Closes this session.intImplements item comparison by PK.protected CartUsed by getCart() to create a new cart.creates a new session context which hides this session's current context within the current thread until it is disabled viaremoveLocalSessionContext().createLocalSessionContext(SessionContext original) Create a new property container that can be used for mass property updates.Returns a SearchContext object which is used for Search operations.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 Stringcreates a session ID for a newly created session.static voidremove the active session from the current thread.protected CartdoCreateCart(ComposedType cartType, User user, Currency curr, Date date, boolean isNet) final booleanprotected UserfindSessionUser(ComposedType userType, String login) protected ComposedTypefindSessionUserType(String sessionTypeString) Generates a value entry for a CookieBasedLoginToken instance, which will be used by some web apps (like printcockpit, hmc, ...) for an 'auto' login processGenerates a value entry for a CookieBasedLoginToken instance, which will be used by some web apps (like printcockpit, hmc, ...) for an 'auto' login processreturns the AccessManager.protected CartgetAttribute(String name) Returns the value of the attribute with the specified name from the attribute map of the current session context.Returns anEnumerationofStringobjects containing the names of all the objects bound to this session.Returns the attribute map of the session context.returns the C2LManager.getCart()Returns the cart which is currently associated with this session.protected ComposedTypeProvides composed type for newly created cart.longstatic JaloSessionReturns the active session for the current thread and tenantstatic JaloSessiongetCurrentSession(Tenant tenant) protected intreturns 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).return the enumeration managerreturns the ExtensionManger.returns the FlexibleSearch.javax.servlet.http.HttpSessionDeprecated.since 5.5.1 session management was changed and this method always returns nullprotected Currencyprotected Language<T extends Item>
Treturns the item with the given PK.<T extends Item>
TDeprecated.since ages - please usegetItem(PK)withPK.parse(String)Collection<? extends Item>getItems(SessionContext ctx, Collection<PK> pks) Returns a collection of items for a given collection of PKs.Collection<? extends Item>getItems(SessionContext ctx, Collection<PK> pks, boolean ignoreMissingItems) Returns a collection of items for a given collection of PKs.Collection<? extends Item>getItems(SessionContext ctx, Collection<PK> pks, boolean ignoreMissingItems, boolean returnMissingAsNull) Returns a collection of items for a given collection of PKs.Collection<? extends Item>getItems(Collection<PK> pks) Returns a collection of items for a given collection of PKs.longreturns the LinkManager.protected SessionContextreturns the properties that was used to create this session.protected LoginTokengetLoginToken(Map props) returns the MediaManager.returns the MetaInformationManager.returns the NumberSeriesManager.returns the OrderManager.returns the ProductManager.Returns the SessionContext currently bound to this session.Returns the session ID.<T extends Tenant>
TintDeprecated.since 5.5.1 session management was changed and this method always return -1returns the TypeManager.getUser()Returns the user which is currently associated with this session.returns the UserManager.booleanhasCart()static booleanHelper method for testing if the current thread has an active session.static booleanhasCurrentSession(Tenant tenant) final inthashCode()Returns the hashcode of this JaloSessionprotected voidinit()Overwrite this class for special initialization logic.protected voidinitSessionContext(Map props) protected Userstatic JaloSessionReturns the active session for the current thread.protected booleanTells 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(Map props) booleanDeprecated.since 5.5.1 session management was changed and this method always return falseprotected booleanTells whether this is not anonymous account or anonymous login is allowed by settinglogin.anonymous.always.disabledconfiguration parameter tofalse.protected booleanstatic booleanisTenantNotAccessible(AbstractTenant tenant) 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 Collection<? extends Item>lookupItems(Tenant tenant, SessionContext ctx, Collection<PK> pks, boolean ignoreMissingItems, boolean returnMissingAsNull) static Collection<? extends Item>lookupItems(SessionContext ctx, Collection<PK> pks) Same asgetItems(SessionContext, Collection)but without requiring a jalo session instance.static Collection<? extends Item>lookupItems(SessionContext ctx, Collection<PK> pks, boolean ignoreMissingItems) Same asgetItems(SessionContext, Collection, boolean)but without requiring a jalo session instance.static Collection<? extends Item>lookupItems(SessionContext ctx, Collection<PK> pks, boolean ignoreMissingItems, boolean returnMissingAsNull) Same asgetItems(SessionContext, Collection, boolean, boolean)but without requiring a jalo session instance.protected voidprotected UserperformLogin(LoginToken token, Map loginProperties) performs login for a given login token and additionally params.protected UserperformLogin(String login, String password, Map loginProperties) performs login for a given login, password and additionally params.protected voidremoveAttribute(String name) Removes the specified attribute from the attribute map of the current session context.voidRemoves a cart from the current session and database, if theItem.remove()fails it is always clearing the internal reference.voidremoves 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.search(GenericQuery query) search(GenericQuery query, SearchContext ctx) Initiates a search with the givenGenericQueryandSearchContext.search(GenericQuery genericQuery, Principal principal, SearchContext searchCtx) Initiates a search with the givenGenericQueryandSearchContext.protected voidsetAttachedCart(Cart cart) setAttribute(String name, Object value) Sets a new value for the attribute with the specified name in the attribute map of the current session context.voidsetAttributes(Map attributes) Replaces multiple session attributes at once.voidvoidsetHttpSessionId(String httpSessionId) Stores a http session id inside this session.protected voidsetLastAccessed(long accessed) protected voidsetLoginProperties(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 effectvoidChanges 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)toString()returns a String representation which contains the SessionID and the UserID which is currently assigned to this Session.voidtouch()mark this session as used.voidchanges the session user including the full login process.voidchanges the session user including the full login process.voidchanges the session user including the full login process.
-
Field Details
-
IS_HMC_SESSION
- See Also:
-
REMOVE_CART_ON_CLOSE
- See Also:
-
SESSION_TIMEOUT
- See Also:
-
PREFETCH_LANGUAGES
- See Also:
-
CART_TYPE
- See Also:
-
HYBRIS_ASSERT_INTERNALS
- See Also:
-
CART
The session attribute key for 'cart'. Use it ingetAttribute(String)for generically access the session cart.- See Also:
-
CTX_NO_PREFTCH_LANGUAGES
-
-
Constructor Details
-
JaloSession
public JaloSession()
-
-
Method Details
-
getTenant
-
assureSessionNotStale
- Returns:
- false whenever given JaloSession has not exactly the same
tenantRestartMarkerwith the Tenant which is referenced by thisJaloSession.
-
isTenantNotAccessible
-
init
protected void init()Overwrite this class for special initialization logic. -
createSessionContext
Creates a newSessionContextinstance setting given context as original. Overwrite this method to change implementation to use forSessionContext.- Since:
- 4.2
-
isDefaultAnonymous
-
initSessionContext
- Throws:
JaloSecurityException
-
initUser
- Throws:
JaloSecurityException
-
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
-
getInitialSessionLanguage
-
getInitialSessionCurrency
-
generateLoginTokenCookieValue
Generates 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
Generates 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 EJBPasswordEncoderNotFoundException Generates and stores a CookieBasedLoginToken instance, for the current session user ('auto' login process) -
performLogin
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(String login, String password, 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
Tells whether this is the anonymous account and anonymous login is disallowed ( using thelogin.anonymous.always.disabledconfiguration parameter ). -
isNotAnonymousOrAnonymousLoginIsAllowed
Tells whether this is not anonymous account or anonymous login is allowed by settinglogin.anonymous.always.disabledconfiguration parameter tofalse. -
findSessionUserType
protected ComposedType findSessionUserType(String sessionTypeString) throws JaloInvalidParameterException - Throws:
JaloInvalidParameterException
-
findSessionUser
protected User findSessionUser(ComposedType userType, 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
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:
IllegalStateException- in case no tenant is active
-
getCurrentSession
-
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.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.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.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.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
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
-
getUser
Returns the user which is currently associated with this session.- Returns:
- the user which is currently associated with this session
-
setUser
Changes the session user without any login processing. Further the session cart is assigned to the new user.- Parameters:
user- the new user
-
transfer
changes 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
changes 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(Map props, boolean activateUserLanguageAndCurrency) throws JaloSecurityException, JaloInvalidParameterException changes 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
-
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
-
setAttachedCart
-
createCart
Used by getCart() to create a new cart.- Returns:
- the new
Cart
-
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, 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
-
restoreSavedCart
Restores all entries from a saved cart to the session cart, thereby removes currently existing entries.- Parameters:
savedCart-
-
appendSavedCart
Appends the entries from the saved cart to the session cart.- Parameters:
appendCart-
-
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
-
setAttributes
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
Returns the attribute map of the session context.- Returns:
- the attribute map of the current session context
-
getAttribute
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
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
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
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
returns the AccessManager.- Returns:
- the AccessManager object
-
getUserManager
returns the UserManager.- Returns:
- the UserManager object
-
getProductManager
returns the ProductManager.- Returns:
- the ProductManager object
-
getNumberSeriesManager
returns the NumberSeriesManager.- Returns:
- the NumberSeriesManager object
-
getFlexibleSearch
returns the FlexibleSearch.- Returns:
- the FlexibleSearch object
-
getC2LManager
returns the C2LManager.- Returns:
- the C2LManager object
-
getMetaInformationManager
returns the MetaInformationManager.- Returns:
- the MetaInformationManager object
-
getMediaManager
returns the MediaManager.- Returns:
- the MediaManager object
-
getOrderManager
returns the OrderManager.- Returns:
- the OrderManager object
-
getLinkManager
returns the LinkManager.- Returns:
- the LinkManager object
-
getExtensionManager
returns the ExtensionManger.- Returns:
- the ExtensionManager object
-
getTypeManager
returns the TypeManager.- Returns:
- the TypeManager object
-
getEnumerationManager
return the enumeration manager- Returns:
- the EnumerationManager object
-
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
-
addLocalSessionContext
-
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
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
-
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
Returns a SearchContext object which is used for Search operations.- Returns:
- a SearchContext object
-
lookupItem
Same asgetItem(PK)but without actually requiring a session instance.- Throws:
JaloItemNotFoundException
-
lookupItem
Same aslookupItem(PK)with the ability to pass the (required) tenant manually.- Throws:
JaloItemNotFoundException
-
lookupItems
public static Collection<? extends Item> lookupItems(SessionContext ctx, Collection<PK> pks) throws JaloItemNotFoundException Same asgetItems(SessionContext, Collection)but without requiring a jalo session instance.- Throws:
JaloItemNotFoundException
-
lookupItems
public static Collection<? extends Item> lookupItems(SessionContext ctx, Collection<PK> pks, boolean ignoreMissingItems) throws JaloItemNotFoundException Same asgetItems(SessionContext, Collection, boolean)but without requiring a jalo session instance.- Throws:
JaloItemNotFoundException
-
lookupItems
public static Collection<? extends Item> lookupItems(SessionContext ctx, 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 Collection<? extends Item> lookupItems(Tenant tenant, SessionContext ctx, Collection<PK> pks, boolean ignoreMissingItems, boolean returnMissingAsNull) throws JaloItemNotFoundException - Throws:
JaloItemNotFoundException
-
getItem
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(since="ages", forRemoval=false) public <T extends Item> T getItem(String pk) throws JaloItemNotFoundException, 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 foundIllegalArgumentException- in case the string is no valid PK representation
-
getItems
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 Collection<? extends Item> getItems(SessionContext ctx, 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 Collection<? extends Item> getItems(SessionContext ctx, 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 Collection<? extends Item> getItems(SessionContext ctx, 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
Returns the session ID. The session id is a generated unique string.- Returns:
- the session id
-
toString
returns a String representation which contains the SessionID and the UserID which is currently assigned to 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
Create a new property container that can be used for mass property updates.- Returns:
- the new property container
- See Also:
-
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
Stores a http session id inside this session. -
getHttpSessionId
-
search
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
-
setPriceFactory
-
getPriceFactory
-
search
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
-
compareTo
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.
-