|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectblackboard.cms.filesystem.CSContext
A Context is the top level state manager for a series of Blackboard Content System calls. For every set of actions grouped together into one transaction, a new context is created and used. A Context instance contains transactional state for that request (ie commit, rollback). All permission checking is done through calls on the Context object.
Without a Context, whenever an exception is thrown, the state of the transactions involved would be unknown. It would not be possible to know which transaction(s) needed to be committed or rolled back. The Context object is used to keep track of that state and allow or block commit attempts. Thus, the Context object can be used to find out if the current transaction can be committed or not.
It is extremely important when using the Context object to ensure that you properly use a try{},catch{},finally{} block to commit() or rollback() each transaction. Not doing so properly can cause deadlocks to occur and cause performance degradation and unexpected behavior.
It is recommended to always use CSContext in the following way:
CSContext ctxCS=null;
try {
ctxCS = CSContext.getContext();
//your code here
} catch (Exception e) {
ctxCS.rollback();
} finally {
if (ctxCS!=null) {
ctxCS.commit();
}
}
bb-manifest note: In order to use these methods, please be sure to include the following permissions
within the bb-manifest under the permissions section:
<permission type="java.lang.RuntimePermission" name="db.connection.*" />
<permission type="attribute" name="user.authinfo" actions="get,set" />
<permission type="attribute" name="user.personalinfo" actions="get,set" />
<permission type="persist" name="user" actions="create,modify,delete" />
<permission type="persist" name="userrole" actions="create,modify,delete" />
<permission type="persist" name="course" actions="create,modify,delete" />
| Method Summary | |
boolean |
canDelete(CSEntry cse)
Checks whether delete permission is granted for the CSEntry named and in this Context instance. |
boolean |
canManage(CSEntry cse)
Checks whether manage permission is granted for the CSEntry named and in this Context instance. |
boolean |
canRead(CSEntry cse)
Checks whether read permission is granted for the CSEntry named and in this Context instance. |
boolean |
canWrite(CSEntry cse)
Checks whether write permission is granted for the CSEntry named and in this Context instance. |
void |
commit()
Commits changes for the transaction in this Context instance. |
CSDirectory |
createDirectory(java.lang.String parentDir,
java.lang.String dirName)
Creates a new Directory |
CSFile |
createFile(java.lang.String parentDir,
java.lang.String fileName,
java.io.InputStream is)
Creates a new File |
CSEntry |
findEntry(java.lang.String path)
Returns a CSEntry for the given file/directory path. |
static CSContext |
getContext()
Returns the CSContext object. |
static CSContext |
getContext(blackboard.data.user.User user)
Returns the CSContext object based on the User object supplied. |
CSDirectory |
getCourseDirectory(blackboard.data.course.Course crs)
Returns a CSDirectory representing the course/org home directory. |
CSDirectory |
getCourseEReservesDirectory(blackboard.data.course.Course crs)
Returns a CSDirectory representing the course/org ereserve directory. |
CSDirectory |
getUserDirectory(blackboard.data.user.User usr)
Returns a CSDirectory representing the user's home directory. |
boolean |
isOwner(CSEntry cse)
Checks whether the user identified by the Context instance is the owner of the file named. |
boolean |
isSuperUser()
Returns the SuperUser attribute for the Context instance. |
void |
isSuperUser(boolean isSuperUser)
Sets the SuperUser attribute for the Context instance. |
void |
rollback()
Rolls back changes for the transaction in this Context instance. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
public static CSContext getContext(blackboard.data.user.User user)
throws CSFileSystemException
CSContext object based on the User object supplied.
user - the User for the Context
CSContext.
CSFileSystemException
public static CSContext getContext()
throws CSFileSystemException
CSContext object.
CSContext.
CSFileSystemException
public void commit()
throws CSFileSystemException
CSFileSystemException
public void rollback()
throws CSFileSystemException
CSFileSystemExceptionpublic boolean isSuperUser()
public void isSuperUser(boolean isSuperUser)
isSuperUser - true if this Context instance should have the SuperUser attribute, false otherwise
public boolean canRead(CSEntry cse)
throws CSFileSystemException
CSEntry named and in this Context instance.
Since every Context instance has a user associated with it , this checks to see if that user has Read permission.
CSFileSystemException
public boolean canWrite(CSEntry cse)
throws CSFileSystemException
CSEntry named and in this Context instance.
Since every Context instance has a user associated with it, this checks to see if that user has Write permission.
CSFileSystemException
public boolean canDelete(CSEntry cse)
throws CSFileSystemException
CSEntry named and in this Context instance.
Since every Context instance has a user associated with it, this checks to see if that user has Delete permission.
CSFileSystemException
public boolean canManage(CSEntry cse)
throws CSFileSystemException
CSEntry named and in this Context instance.
Since every Context instance has a user associated with it, this checks to see if that user has Manage permission.
CSFileSystemException
public boolean isOwner(CSEntry cse)
throws CSFileSystemException
CSFileSystemException
public CSEntry findEntry(java.lang.String path)
throws CSFileSystemException
CSEntry for the given file/directory path.
path - a string representing the file/directory path.
CSEntry representing the file/directory from the given path.
CSFileSystemException
public CSFile createFile(java.lang.String parentDir,
java.lang.String fileName,
java.io.InputStream is)
throws CSFileSystemException
parentDir - a String representing the parent directory for where the file will residefileName - a String representing the name of the fileis - The Input Stream for the file contents.
CSFile representing the new file.
CSFileSystemException
public CSDirectory createDirectory(java.lang.String parentDir,
java.lang.String dirName)
throws CSFileSystemException
parentDir - a String representing the parent directory for where the directory will residedirName - a String representing the name of the directory
CSDirectory representing the new directory.
CSFileSystemException
public CSDirectory getUserDirectory(blackboard.data.user.User usr)
throws CSFileSystemException
CSDirectory representing the user's home directory. Returns null if the user does not get a home directory.
CSDirectory representing the user's home directory.
CSFileSystemException
public CSDirectory getCourseDirectory(blackboard.data.course.Course crs)
throws CSFileSystemException
CSDirectory representing the course/org home directory. Returns null if the course/org does not get a home directory.
crs - the specified course/org
CSDirectory representing the course/org home directory.
CSFileSystemException
public CSDirectory getCourseEReservesDirectory(blackboard.data.course.Course crs)
throws CSFileSystemException
CSDirectory representing the course/org ereserve directory. Returns null if the course does not get a ereserve directory. Returns null if it is an org.
crs - the specified course
CSDirectory representing the course/org ereserve directory.
CSFileSystemException
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||