Added lastModified property that contains a date either of when the session
was created or when the session was last logged in or out. The property can also be set from script code.
This commit is contained in:
parent
113ea0aecc
commit
b2862b95bb
2 changed files with 21 additions and 2 deletions
|
@ -30,7 +30,7 @@ public class Session implements Serializable {
|
||||||
// this stays the same across logins and logouts.
|
// this stays the same across logins and logouts.
|
||||||
public TransientNode cacheNode;
|
public TransientNode cacheNode;
|
||||||
|
|
||||||
long onSince, lastTouched;
|
long onSince, lastTouched, lastModified;
|
||||||
|
|
||||||
// used to remember messages to the user between requests -
|
// used to remember messages to the user between requests -
|
||||||
// used for redirects.
|
// used for redirects.
|
||||||
|
@ -43,7 +43,7 @@ public class Session implements Serializable {
|
||||||
this.userHandle = null;
|
this.userHandle = null;
|
||||||
cacheNode = new TransientNode ("session");
|
cacheNode = new TransientNode ("session");
|
||||||
onSince = System.currentTimeMillis ();
|
onSince = System.currentTimeMillis ();
|
||||||
lastTouched = onSince;
|
lastTouched = lastModified = onSince;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -57,6 +57,7 @@ public class Session implements Serializable {
|
||||||
userHandle = ((Node)usernode).getHandle();
|
userHandle = ((Node)usernode).getHandle();
|
||||||
uid = usernode.getElementName();
|
uid = usernode.getElementName();
|
||||||
}
|
}
|
||||||
|
lastModified = System.currentTimeMillis ();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -65,6 +66,7 @@ public class Session implements Serializable {
|
||||||
public void logout() {
|
public void logout() {
|
||||||
userHandle = null;
|
userHandle = null;
|
||||||
uid = null;
|
uid = null;
|
||||||
|
lastModified = System.currentTimeMillis ();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isLoggedIn() {
|
public boolean isLoggedIn() {
|
||||||
|
@ -108,6 +110,15 @@ public class Session implements Serializable {
|
||||||
return lastTouched;
|
return lastTouched;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long lastModified () {
|
||||||
|
return lastModified;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLastModified (Date date) {
|
||||||
|
if (date != null)
|
||||||
|
lastModified = date.getTime ();
|
||||||
|
}
|
||||||
|
|
||||||
public long onSince () {
|
public long onSince () {
|
||||||
return onSince;
|
return onSince;
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,5 +67,13 @@ public class SessionBean implements Serializable {
|
||||||
return new Date (session.onSince ());
|
return new Date (session.onSince ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Date getLastModified () {
|
||||||
|
return new Date (session.lastModified ());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLastModified (Date date) {
|
||||||
|
session.setLastModified (date);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue