Class CommandContext
java.lang.Object
org.deltava.jdbc.ConnectionContext
org.deltava.commands.HTTPContext
org.deltava.commands.CommandContext
- All Implemented Interfaces:
SecurityContext
A class for storing run-time data needed for Command invocations. This class handles reserving and releasing JDBC
Connections, since by doing so we can easily return connections back to the pool in a finally block without
nasty scope issues.
- Since:
- 1.0
- Version:
- 12.4
- Author:
- Luke
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class ConnectionContext
ConnectionContext.ConnectionPoolException -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringFields inherited from class HTTPContext
_req, _rsp, ADDRINFO_ATTR_NAME, CAPTCHA_ATTR_NAME, CSP_ATTR_NAME, HTTPCTXT_ATTR_NAME, RTLIMIT_ATTR_NAME, SU_ATTR_NAME, USER_ATTR_NAME, USERAGENT_ATTR_NAMEModifier and TypeFieldDescriptionprotected final jakarta.servlet.http.HttpServletRequestThe HTTP request.protected final jakarta.servlet.http.HttpServletResponseThe HTTP response.static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final String -
Constructor Summary
ConstructorsConstructorDescriptionCommandContext(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse rsp) Creates a new Command context from an HTTP Servlet Request/Resposne pair. -
Method Summary
Modifier and TypeMethodDescriptionintgetID()Returns a document ID as an integer.Returns the Command Result object.longrelease()Returns a JDBC Connection to the connection pool.voidsetMessage(String msg) Passes a system message into the response.Methods inherited from class HTTPContext
addCookie, clearCookie, getCmdParameter, getCookie, getFile, getParameter, getParameters, getParameters, getRequest, getResponse, getRoles, getSession, getUser, isAuthenticated, isSuperUser, isUserInRole, passedCAPTCHA, setAttribute, setExpiry, setHeader, setHeader, setUserModifier and TypeMethodDescriptionvoidaddCookie(jakarta.servlet.http.Cookie c) Adds a Cookie to the response.voidclearCookie(String name) Clears a Cookie in the response.getCmdParameter(int prmType, Object defaultValue) Returns one of the special command parameters.jakarta.servlet.http.CookieReturns an HTTP cookie.Returns the value of an uploaded file object.getParameter(String pName) Returns the value of a request parameter.getParameters(String pName) Returns the values of a collection of request parameters.getParameters(String pName, Collection<String> deflt) Returns the values of a collection of request parameters.jakarta.servlet.http.HttpServletRequestReturns the current HTTP Servlet Request.jakarta.servlet.http.HttpServletResponseReturns the current HTTP Servlet Response.getRoles()Returns the list of roles for the user.jakarta.servlet.http.HttpSessionReturns the current HTTP session.getUser()Returns the authenticated user object.booleanReturns if this command is being invoked by an authenticated user.booleanReturns whether an Administrator is impersonating another user.booleanisUserInRole(String roleName) Returns if the currently logged in user is a member of a particular role.booleanReturns whether the user has passed CAPTCHA validation.voidsetAttribute(String name, Object value, Command.Scope scope) Sets an attribute in a particular context.voidsetExpiry(int expireInterval) Sets an Expires header on the response.voidHelper method to set a numeric response header.voidHelper method to set a response header.voidUpdates the User executing this operation.Methods inherited from class ConnectionContext
commitTX, getConnection, getDB, hasConnection, rollbackTX, setDB, startTXModifier and TypeMethodDescriptionvoidcommitTX()Commits the current JDBC transaction.Reserves a JDBC Connection from the connection pool.getDB()Returns the default database name.booleanReturns whether a JDBC connection has been reserved by this context.voidRolls back the current JDBC transaction.voidUpdates the default database name.voidstartTX()Starts a JDBC transaction block, by turning off autoCommit on the reserved Connection.
-
Field Details
-
AUTH_COOKIE_NAME
- See Also:
-
USER_COOKIE_NAME
- See Also:
-
USRLISTENER_ATTR_NAME
- See Also:
-
INVALIDREQ_ATTR_NAME
- See Also:
-
SYSMSG_ATTR_NAME
- See Also:
-
-
Constructor Details
-
CommandContext
public CommandContext(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse rsp) Creates a new Command context from an HTTP Servlet Request/Resposne pair.- Parameters:
req- the Servlet Requestrsp- the Servlet Response
-
-
Method Details
-
release
public long release()Description copied from class:ConnectionContextReturns a JDBC Connection to the connection pool.- Overrides:
releasein classConnectionContext- Returns:
- the time the connection was in use, in milliseconds
-
getResult
Returns the Command Result object.- Returns:
- the results of the command invocation
-
setMessage
Passes a system message into the response.- Parameters:
msg- the System Message
-
getID
Returns a document ID as an integer.- Returns:
- the datbase ID, or 0 if not found
- Throws:
CommandException- if the ID cannot be parsed into a number
-