Package org.openbravo.database
Class SessionInfo
- java.lang.Object
-
- org.openbravo.database.SessionInfo
-
public class SessionInfo extends Object
This class is used to maintain session information which will be used for audit purposes.
-
-
Field Summary
Fields Modifier and Type Field Description static String
IMPORT_ENTRY_PROCESS
-
Constructor Summary
Constructors Constructor Description SessionInfo()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static void
auditThisThread(boolean shouldAudit)
Set this value tofalse
to prevent context info to be set in DBstatic Object
getAdditionalInfo(String property)
Retrieves the value of an additional session info property which has been previously saved withsetAddionalInfo(String, Object)
.static String
getCommand()
static String
getModuleId()
static String
getProcessId()
static String
getProcessType()
static String
getQueryProfile()
static String
getSessionId()
static String
getUserId()
static void
infoChanged()
Forces changed info flag so next time it is checked it session info will be set in DBstatic void
init()
Sets all session information to null.static void
initDB(Connection conn, String rdbms)
Creates the needed infrastructure for audit.static boolean
isInitialized()
static boolean
isUsageAuditActive()
static void
saveContextInfoIntoDB(Connection conn)
Saves currently stored context information into DB.static void
setAddionalInfo(String property, Object value)
Sets the value of an additional session info property.static void
setAuditActive(boolean isAuditActive)
static void
setCommand(String comm)
static void
setDBSessionInfo(Connection conn)
Deprecated.In most of the cases this method is no longer required to be invokedstatic void
setDBSessionInfo(Connection conn, String rdbms)
Deprecated.static void
setModuleId(String moduleId)
static void
setProcessId(String processId)
static void
setProcessType(String processType)
static void
setQueryProfile(String profile)
static void
setSessionId(String session)
static void
setUsageAuditActive(boolean usageAuditActive)
static void
setUserId(String user)
-
-
-
Field Detail
-
IMPORT_ENTRY_PROCESS
public static final String IMPORT_ENTRY_PROCESS
- See Also:
- Constant Field Values
-
-
Method Detail
-
init
public static void init()
Sets all session information to null. Called at the end of http-request handling, to reset the audit information for that thread.
-
initDB
public static void initDB(Connection conn, String rdbms)
Creates the needed infrastructure for audit. Which is temporary session table for PostgreSQL connections. Called whenever a new physical db-connection is created.- Parameters:
conn
- Connection to databaserdbms
- Database, only action is take for POSTGRESQL
-
setDBSessionInfo
@Deprecated public static void setDBSessionInfo(Connection conn)
Deprecated.In most of the cases this method is no longer required to be invoked- See Also:
saveContextInfoIntoDB(Connection)
-
saveContextInfoIntoDB
public static void saveContextInfoIntoDB(Connection conn)
Saves currently stored context information into DB. Generally, this method shouldn't be directly invoked, as the Platform already does it when flushing changes to DB. Only in case Openbravo platform is bypassed (ie. DB operations performed on a manually obtained connection), this method must be manually invoked.- Parameters:
conn
- The connection where the session information will be stored in, note it must be the same one performing DB modifications so audit trail triggers can retrieve the session information.
-
setDBSessionInfo
@Deprecated public static void setDBSessionInfo(Connection conn, String rdbms)
Deprecated.Initialized DB with temporary table and sets session information on it.- Parameters:
conn
- Connection where the session information will be stored inrdbms
- Database type
-
setUserId
public static void setUserId(String user)
-
getUserId
public static String getUserId()
-
setProcessId
public static void setProcessId(String processId)
-
getProcessId
public static String getProcessId()
-
setProcessType
public static void setProcessType(String processType)
-
getProcessType
public static String getProcessType()
-
setSessionId
public static void setSessionId(String session)
-
infoChanged
public static void infoChanged()
Forces changed info flag so next time it is checked it session info will be set in DB
-
getCommand
public static String getCommand()
-
setCommand
public static void setCommand(String comm)
-
getQueryProfile
public static String getQueryProfile()
-
setQueryProfile
public static void setQueryProfile(String profile)
-
getAdditionalInfo
public static Object getAdditionalInfo(String property)
Retrieves the value of an additional session info property which has been previously saved withsetAddionalInfo(String, Object)
.- Parameters:
property
- The name of the additional session info property- Returns:
- the value stored for the given property or null in case a value can not be found
-
setAddionalInfo
public static void setAddionalInfo(String property, Object value)
Sets the value of an additional session info property.- Parameters:
property
- The name of the additional session info propertyvalue
- The value to be assigned to the property
-
getSessionId
public static String getSessionId()
-
setAuditActive
public static void setAuditActive(boolean isAuditActive)
-
isInitialized
public static boolean isInitialized()
-
getModuleId
public static String getModuleId()
-
setModuleId
public static void setModuleId(String moduleId)
-
isUsageAuditActive
public static boolean isUsageAuditActive()
-
setUsageAuditActive
public static void setUsageAuditActive(boolean usageAuditActive)
-
auditThisThread
public static void auditThisThread(boolean shouldAudit)
Set this value tofalse
to prevent context info to be set in DB
-
-