|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.dspace.core.Context
public class Context
Class representing the context of a particular DSpace operation. This stores information such as the current authenticated user and the database connection being used.
Typical use of the context object will involve constructing one, and setting
the current user if one is authenticated. Several operations may be performed
using the context object. If all goes well, complete is called
to commit the changes and free up any resources used by the context. If
anything has gone wrong, abort is called to roll back any
changes and free up the resources.
The context object is also used as a cache for CM API objects.
| Constructor Summary | |
|---|---|
Context()
Construct a new context object. |
|
| Method Summary | |
|---|---|
void |
abort()
Close the context, without committing any of the changes performed using this context. |
void |
addEvent(Event event)
Add an event to be dispatched when this context is committed. |
void |
cache(Object o,
int id)
Store an object in the object cache. |
void |
clearCache()
Remove all the objects from the object cache |
void |
commit()
Commit any transaction that is currently in progress, but do not close the context. |
void |
complete()
Close the context object after all of the operations performed in the context have completed successfully. |
protected void |
finalize()
|
Object |
fromCache(Class<?> objectClass,
int id)
Store an object in the object cache. |
int |
getCacheSize()
Get the count of cached objects, which you can use to instrument an application to track whether it is "leaking" heap space by letting cached objects build up. |
Locale |
getCurrentLocale()
Gets the current Locale |
EPerson |
getCurrentUser()
Get the current (authenticated) user |
Connection |
getDBConnection()
Get the database connection associated with the context |
LinkedList<Event> |
getEvents()
Get the current event list. |
String |
getExtraLogInfo()
Get extra information to be logged with message logged in the scope of this context. |
Group[] |
getSpecialGroups()
gets an array of all of the special groups that current user is a member of |
boolean |
hasEvents()
|
boolean |
ignoreAuthorization()
Find out if the authorisation system should be ignored for this context. |
boolean |
inSpecialGroup(int groupID)
test if member of special group |
boolean |
isValid()
Find out if this context is valid. |
Event |
pollEvent()
Retrieves the first element in the events list & removes it from the list of events once retrieved |
void |
removeCached(Object o,
int id)
Remove an object from the object cache. |
void |
restoreAuthSystemState()
Restore the previous Authorisation System State. |
void |
setCurrentLocale(Locale locale)
set the current Locale |
void |
setCurrentUser(EPerson user)
Set the current user. |
void |
setDispatcher(String dispatcher)
Select an event dispatcher, null selects the default |
void |
setExtraLogInfo(String info)
Set extra information that should be added to any message logged in the scope of this context. |
void |
setIgnoreAuthorization(boolean b)
Deprecated. use turnOffAuthorisationSystem() for make the change and restoreAuthSystemState() when change are not more required |
void |
setSpecialGroup(int groupID)
set membership in a special group |
void |
turnOffAuthorisationSystem()
Turn Off the Authorisation System for this context and store this change in a history for future use. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Context()
throws SQLException
SQLException - if there was an error obtaining a database connection| Method Detail |
|---|
public Connection getDBConnection()
public void setCurrentUser(EPerson user)
user - the new current user, or null if no user is
authenticatedpublic EPerson getCurrentUser()
null if no user is
authenticatedpublic Locale getCurrentLocale()
public void setCurrentLocale(Locale locale)
locale - the current Localepublic boolean ignoreAuthorization()
true if authorisation should be ignored for this
session.public void turnOffAuthorisationSystem()
public void restoreAuthSystemState()
mycontext.turnOffAuthorisationSystem();
some java code that require no authorisation check
mycontext.restoreAuthSystemState();
If Context debug is enabled, the correct sequence calling will be
checked and a warning will be displayed if not.
public void setIgnoreAuthorization(boolean b)
b - if true, authorisation should be ignored for this
session.public void setExtraLogInfo(String info)
setExtraLogInfo("session_id="+request.getSession().getId());
info - the extra information to logpublic String getExtraLogInfo()
null
public void complete()
throws SQLException
SQLException - if there was an error completing the database transaction
or closing the connection
public void commit()
throws SQLException
SQLException - if there was an error completing the database transaction
or closing the connectionpublic void setDispatcher(String dispatcher)
null selects the default
public void addEvent(Event event)
event - public LinkedList<Event> getEvents()
public boolean hasEvents()
public Event pollEvent()
null if the list is emptypublic void abort()
public boolean isValid()
false if this
context has been aborted or completed.
true if the context is still valid, otherwise
false
public Object fromCache(Class<?> objectClass,
int id)
objectClass - Java Class of object to check for in cacheid - ID of object in cache
null if it's not
cached.
public void cache(Object o,
int id)
o - the object to storeid - the object's ID
public void removeCached(Object o,
int id)
o - the object to removeid - the object's IDpublic void clearCache()
public int getCacheSize()
public void setSpecialGroup(int groupID)
groupID - special group's IDpublic boolean inSpecialGroup(int groupID)
groupID - ID of special group to test
public Group[] getSpecialGroups()
throws SQLException
SQLException
protected void finalize()
throws Throwable
finalize in class ObjectThrowable
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||