Package helma.framework.core

# Class Session

java.lang.Object
helma.framework.core.Session

All Implemented Interfaces:
  `Serializable`

public class Session extends Object implements Serializable
This represents a session currently using the Hop application. This includes anybody who happens to request a page from this application. Depending on whether the user is logged in or not, the session holds a persistent user node.

See Also:
  - Serialized Form

## Field Summary

Fields
Modifier and Type
Field
Description
`protected Application`
`app`
`protected long`
`cacheLastModified`
`protected INode`
`cacheNode`
`protected StringBuffer`
`debugBuffer`
`protected long`
`lastModified`
`protected long`
`lastTouched`
`protected String`
`message`
`protected boolean`
`modifiedInRequest`
`protected long`
`onSince`
`protected boolean`
`registered`
`protected String`
`sessionId`
`protected String`
`uid`
`protected HashMap`
`uploads`
`protected NodeHandle`
`userHandle`

## Constructor Summary

Constructors
Constructor
Description
`Session(String sessionId, Application app)`
Creates a new Session object.

## Method Summary

Modifier and Type
Method
Description
`void`
`commit(RequestEvaluator reval, SessionManager smgr)`
Called after a request has been handled.
`protected UploadStatus`
`createUpload(String uploadId)`
`Application`
`getApp()`
Get this session's application
`INode`
`getCacheNode()`
Gets the transient cache node.
`StringBuffer`
`getDebugBuffer()`
Return the debug buffer that is to be displayed upon the next request within this session.
`String`
`getMessage()`
Return the message that is to be displayed upon the next request within this session.
`String`
`getSessionId()`
Return this session's id.
`String`
`getUID()`
Get the persistent user id of a registered user.
`protected UploadStatus`
`getUpload(String uploadId)`
`NodeHandle`
`getUserHandle()`
Get the Node handle for the current user, if logged in.
`INode`
`getUserNode()`
Gets the user Node from this Application's NodeManager.
`boolean`
`isLoggedIn()`
Returns true if this session is currently associated with a user object.
`long`
`lastModified()`
Returns the time this session was last modified, meaning the last time its user status changed or its cache node was modified.
`long`
`lastTouched()`
Returns the time this session was last touched.
`void`
`login(INode usernode)`
Attach the given user node to this session.
`boolean`
`login(String userName, String password)`
Try logging in this session given the userName and password.
`void`
`logout()`
Remove this sessions's user node.
`long`
`onSince()`
Return the time this session was created.
`protected void`
`pruneUploads()`
`void`
`recoverResponseMessages(ResponseTrans res)`
Set the user and debug messages over from a previous response.
`void`
`setApp(Application app)`
Set this session's application
`void`
`setCacheNode(INode node)`
Set the cache node for this session.
`void`
`setDebugBuffer(StringBuffer buffer)`
Set the debug buffer to be displayed to this session's user.
`void`
`setLastModified(long l)`
Set the last modified time on this session.
`void`
`setMessage(String msg)`
Set a message to be displayed to this session's user.
`void`
`setUID(String uid)`
Set the persistent user id of a registered user.
`void`
`setUserHandle(NodeHandle handle)`
Set the user handle for this session.
`void`
`storeResponseMessages(ResponseTrans res)`
Remember the response's user and debug messages for a later response.
`String`
`toString()`
Return a string representation for this session.
`void`
`touch()`
Called at the beginning of a request to let the session know it's being used.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

## Field Details

### app

protected transient Application app

### sessionId

protected String sessionId

### uid

protected String uid

### userHandle

protected NodeHandle userHandle

### cacheNode

protected INode cacheNode

### onSince

protected long onSince

### lastTouched

protected long lastTouched

### lastModified

protected long lastModified

### cacheLastModified

protected long cacheLastModified

### message

protected String message

### debugBuffer

protected StringBuffer debugBuffer

### uploads

protected HashMap uploads

### modifiedInRequest

protected transient boolean modifiedInRequest

### registered

protected transient boolean registered

## Constructor Details

### Session

public Session(String sessionId, Application app)
Creates a new Session object.

Parameters:
  `sessionId` - ...
  `app` - ...

## Method Details

### login

public void login(INode usernode)
Attach the given user node to this session.

### login

public boolean login(String userName, String password)
Try logging in this session given the userName and password.

Parameters:
  `userName` - the user name
  `password` - the password
Returns:
  true if session was logged in.

### logout

public void logout()
Remove this sessions's user node.

### isLoggedIn

public boolean isLoggedIn()
Returns true if this session is currently associated with a user object.

Returns:
  ...

### setUserHandle

public void setUserHandle(NodeHandle handle)
Set the user handle for this session.

### getUserHandle

public NodeHandle getUserHandle()
Get the Node handle for the current user, if logged in.

### getUserNode

public INode getUserNode()
Gets the user Node from this Application's NodeManager.

### setCacheNode

public void setCacheNode(INode node)
Set the cache node for this session.

### getCacheNode

public INode getCacheNode()
Gets the transient cache node.

### getApp

public Application getApp()
Get this session's application

Returns:
  ...

### setApp

public void setApp(Application app)
Set this session's application

Parameters:
  `app` - ...

### getSessionId

public String getSessionId()
Return this session's id.

Returns:
  ...

### touch

public void touch()
Called at the beginning of a request to let the session know it's being used.

### commit

public void commit(RequestEvaluator reval, SessionManager smgr)
Called after a request has been handled.

Parameters:
  `reval` - the request evaluator that handled the request

### lastTouched

public long lastTouched()
Returns the time this session was last touched.

Returns:
  ...

### lastModified

public long lastModified()
Returns the time this session was last modified, meaning the last time its user status changed or its cache node was modified.

Returns:
  ...

### setLastModified

public void setLastModified(long l)
Set the last modified time on this session.

Parameters:
  `l` - the timestamp

### onSince

public long onSince()
Return the time this session was created.

Returns:
  ...

### toString

public String toString()
Return a string representation for this session.

Overrides:
  `toString` in class `Object`
Returns:
  ...

### getUID

public String getUID()
Get the persistent user id of a registered user. This is usually the user name, or null if the user is not logged in.

### setUID

public void setUID(String uid)
Set the persistent user id of a registered user.

Parameters:
  `uid` - the user name, or null if the user is not logged in.

### recoverResponseMessages

public void recoverResponseMessages(ResponseTrans res)
Set the user and debug messages over from a previous response. This is used for redirects, where messages can't be displayed immediately.

Parameters:
  `res` - the response to set the messages on

### storeResponseMessages

public void storeResponseMessages(ResponseTrans res)
Remember the response's user and debug messages for a later response. This is used for redirects, where messages can't be displayed immediately.

Parameters:
  `res` - the response to retrieve the messages from

### getMessage

public String getMessage()
Return the message that is to be displayed upon the next request within this session.

Returns:
  the message, or null if none was set.

### setMessage

public void setMessage(String msg)
Set a message to be displayed to this session's user. This can be used to save a message over to the next request when the current request can't be used to display a user visible message.

Parameters:
  `msg` - the message

### getDebugBuffer

public StringBuffer getDebugBuffer()
Return the debug buffer that is to be displayed upon the next request within this session.

Returns:
  the debug buffer, or null if none was set.

### setDebugBuffer

public void setDebugBuffer(StringBuffer buffer)
Set the debug buffer to be displayed to this session's user. This can be used to save the debug buffer over to the next request when the current request can't be used to display a user visible message.

Parameters:
  `buffer` - the buffer

### createUpload

protected UploadStatus createUpload(String uploadId)

### getUpload

protected UploadStatus getUpload(String uploadId)

### pruneUploads

protected void pruneUploads()