| java.lang.Object org.dspace.core.Context
Context | public class Context (Code) | | 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.
version: $Revision: 2104 $ |
Constructor Summary | |
public | Context() Construct a new context object. |
Context | public Context() throws SQLException(Code) | | Construct a new context object. A database connection is opened. No user
is authenticated.
exception: SQLException - if there was an error obtaining a database connection |
abort | public void abort()(Code) | | Close the context, without committing any of the changes performed using
this context. The database connection is freed. No exception is thrown if
there is an error freeing the database connection, since this method may
be called as part of an error-handling routine where an SQLException has
already been thrown.
|
addEvent | public void addEvent(Event event)(Code) | | Add an event to be dispatched when this context is committed.
Parameters: event - |
cache | public void cache(Object o, int id)(Code) | | Store an object in the object cache.
Parameters: o - the object to store Parameters: id - the object's ID |
clearCache | public void clearCache()(Code) | | Remove all the objects from the object cache
|
commit | public void commit() throws SQLException(Code) | | Commit any transaction that is currently in progress, but do not close
the context.
exception: SQLException - if there was an error completing the database transactionor closing the connection |
complete | public void complete() throws SQLException(Code) | | Close the context object after all of the operations performed in the
context have completed succesfully. Any transaction with the database is
committed.
exception: SQLException - if there was an error completing the database transactionor closing the connection |
finalize | protected void finalize()(Code) | | |
fromCache | public Object fromCache(Class objectClass, int id)(Code) | | Store an object in the object cache.
Parameters: objectClass - Java Class of object to check for in cache Parameters: id - ID of object in cache the object from the cache, or null if it's notcached. |
getCurrentLocale | public Locale getCurrentLocale()(Code) | | Gets the current Locale
Localethe current Locale |
getCurrentUser | public EPerson getCurrentUser()(Code) | | Get the current (authenticated) user
the current user, or null if no user isauthenticated |
getDBConnection | public Connection getDBConnection()(Code) | | Get the database connection associated with the context
the database connection |
getEvents | public List<Event> getEvents()(Code) | | Get the current event list. If there is a separate list of events from
already-committed operations combine that with current list.
List of all available events. |
getExtraLogInfo | public String getExtraLogInfo()(Code) | | Get extra information to be logged with message logged in the scope of
this context.
the extra log info - guaranteed non- null |
ignoreAuthorization | public boolean ignoreAuthorization()(Code) | | Find out if the authorisation system should be ignored for this context.
true if authorisation should be ignored for thissession. |
inSpecialGroup | public boolean inSpecialGroup(int groupID)(Code) | | test if member of special group
Parameters: groupID - ID of special group to test true if member |
isValid | public boolean isValid()(Code) | | Find out if this context is valid. Returns false if this
context has been aborted or completed.
true if the context is still valid, otherwisefalse |
removeCached | public void removeCached(Object o, int id)(Code) | | Remove an object from the object cache.
Parameters: o - the object to remove Parameters: id - the object's ID |
setCurrentLocale | public void setCurrentLocale(Locale locale)(Code) | | set the current Locale
Parameters: Locale - the current Locale |
setCurrentUser | public void setCurrentUser(EPerson user)(Code) | | Set the current user. Authentication must have been performed by the
caller - this call does not attempt any authentication.
Parameters: user - the new current user, or null if no user isauthenticated |
setDispatcher | public void setDispatcher(String dispatcher)(Code) | | Select an event dispatcher, null selects the default
|
setExtraLogInfo | public void setExtraLogInfo(String info)(Code) | | Set extra information that should be added to any message logged in the
scope of this context. An example of this might be the session ID of the
current Web user's session:
setExtraLogInfo("session_id="+request.getSession().getId());
Parameters: info - the extra information to log |
setIgnoreAuthorization | public void setIgnoreAuthorization(boolean b)(Code) | | Specify whether the authorisation system should be ignored for this
context. This should be used sparingly.
Parameters: b - if true , authorisation should be ignored forthis session. |
setSpecialGroup | public void setSpecialGroup(int groupID)(Code) | | set membership in a special group
Parameters: groupID - special group's ID |
|
|