public class CmsDbContext extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected java.util.Map<java.lang.String,java.lang.Object> |
m_attributes
Context attributes.
|
protected CmsFlexRequestContextInfo |
m_flexRequestContextInfo
The current Flex request context info (if available).
|
protected CmsUUID |
m_projectId
The id of the project for the context.
|
protected CmsRequestContext |
m_requestContext
The wrapped user request context.
|
Constructor and Description |
---|
CmsDbContext()
Creates a new, empty database context.
|
CmsDbContext(CmsRequestContext context)
Creates a new database context initialized with the given user request context.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clears this database context.
|
CmsProject |
currentProject()
Returns the current users project.
|
CmsUser |
currentUser()
Returns the current user.
|
java.lang.Object |
getAttribute(java.lang.String key)
Get an attribute from the DB context.
|
CmsFlexRequestContextInfo |
getFlexRequestContextInfo()
Returns the current Flex request context info.
|
I_CmsHistoryDriver |
getHistoryDriver(CmsUUID projectId)
Gets the history driver associated with this database context.
|
I_CmsProjectDriver |
getProjectDriver(CmsUUID projectId)
Gets the project driver associated with this database context.
|
CmsUUID |
getProjectId()
Returns the project id of the context.
|
CmsRequestContext |
getRequestContext()
Returns the request context.
|
I_CmsUserDriver |
getUserDriver(CmsUUID projectId)
Gets the user driver associated with this database context.
|
I_CmsVfsDriver |
getVfsDriver(CmsUUID projectId)
Gets the VFS driver associated with this database context.
|
boolean |
isDefaultDbContext()
Checks if the database context uses the default implementation.
|
void |
pop()
Processes the current database context.
|
void |
removeAttribute(java.lang.String key)
Removes the given attribute from the DB context.
|
java.lang.String |
removeSiteRoot(java.lang.String resourcename)
Removes the current site root prefix from the absolute path in the resource name,
that is adjusts the resource name for the current site root.
|
void |
report(I_CmsReport report,
CmsMessageContainer message,
java.lang.Throwable throwable)
Reports an error to the given report (if available) and to the OpenCms log file.
|
void |
rollback()
Rolls back current transaction.
|
void |
setAttribute(java.lang.String key,
java.lang.Object value)
Sets an attribute in the DB context.
|
void |
setProjectId(CmsUUID projectId)
Sets the project id of the context.
|
void |
throwException(CmsMessageContainer message,
java.lang.Throwable throwable)
Returns an exception of the same type as
throwable , if throwable is an OpenCms Exception
with the message as a CmsMessageContainer and the throwable as a cause. |
protected java.util.Map<java.lang.String,java.lang.Object> m_attributes
protected CmsFlexRequestContextInfo m_flexRequestContextInfo
protected CmsUUID m_projectId
protected CmsRequestContext m_requestContext
public CmsDbContext()
public CmsDbContext(CmsRequestContext context)
context
- the current users request contextpublic void clear()
public CmsProject currentProject()
public CmsUser currentUser()
public java.lang.Object getAttribute(java.lang.String key)
key
- the attribute keypublic CmsFlexRequestContextInfo getFlexRequestContextInfo()
public I_CmsHistoryDriver getHistoryDriver(CmsUUID projectId)
projectId
- the project id for which the history driver should be retrievedpublic I_CmsProjectDriver getProjectDriver(CmsUUID projectId)
projectId
- the project id for which the project driver should be retrievedpublic CmsUUID getProjectId()
public CmsRequestContext getRequestContext()
public I_CmsUserDriver getUserDriver(CmsUUID projectId)
projectId
- the project id for which the user driver should be retrievedpublic I_CmsVfsDriver getVfsDriver(CmsUUID projectId)
projectId
- the project id for which the VFS driver should be retrievedpublic boolean isDefaultDbContext()
true
if the database context uses the default implementationpublic void pop() throws CmsException
CmsException
- if something goes wrongpublic void removeAttribute(java.lang.String key)
key
- the attribute keypublic java.lang.String removeSiteRoot(java.lang.String resourcename)
If no user request context is available, the given resource name is returned unchanged.
resourcename
- the resource namepublic void report(I_CmsReport report, CmsMessageContainer message, java.lang.Throwable throwable) throws CmsVfsException, CmsException
report
- the report to write the error tomessage
- the message to write to the report / logthrowable
- the exception to write to the report / logCmsException
- if the throwable
parameter is not null
and a CmsException
CmsVfsException
- if the throwable
parameter is not null
and no CmsException
public void rollback()
public void setAttribute(java.lang.String key, java.lang.Object value)
key
- the attribute keyvalue
- the attribute valuepublic void setProjectId(CmsUUID projectId)
projectId
- the id of the project to setpublic void throwException(CmsMessageContainer message, java.lang.Throwable throwable) throws CmsVfsException, CmsException
throwable
, if throwable
is an OpenCms Exception
with the message as a CmsMessageContainer
and the throwable
as a cause.message
- the message container for the exception to createthrowable
- the cause of the exceptionCmsException
- if the throwable
parameter is not null
and a CmsException
CmsVfsException
- if the throwable
parameter is not null
and no CmsException