Package org.h2.server.web
Class WebApp
- java.lang.Object
-
- org.h2.server.web.WebApp
-
- Direct Known Subclasses:
WebThread
public class WebApp extends java.lang.Object
For each connection to a session, an object of this class is created. This class is used by the H2 Console.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
WebApp.IndexInfo
This class represents index information for the GUI.
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Properties
attributes
The session attributesprotected boolean
cache
Whether the response can be cached.protected java.lang.String
headerLanguage
The language in the HTTP header.protected java.lang.String
mimeType
The mime type of the current response.private Profiler
profiler
protected WebServer
server
The web server.protected WebSession
session
The session.protected boolean
stop
Whether to close the connection.private static java.util.Comparator<DbTableOrView>
SYSTEM_SCHEMA_COMPARATOR
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static int
addColumns(boolean mainSchema, DbTableOrView table, java.lang.StringBuilder builder, int treeIndex, boolean showColumnTypes, java.lang.StringBuilder columnsBuilder)
private static int
addIndexes(boolean mainSchema, java.sql.DatabaseMetaData meta, java.lang.String table, java.lang.String schema, java.lang.StringBuilder buff, int treeIndex)
private static int
addTableOrView(DbSchema schema, boolean mainSchema, java.lang.StringBuilder builder, int treeIndex, java.sql.DatabaseMetaData meta, boolean showColumns, java.lang.String indentation, boolean isOracle, boolean notManyTables, DbTableOrView table, boolean isView, java.sql.PreparedStatement prep, java.lang.String indentNode)
private int
addTablesAndViews(DbSchema schema, boolean mainSchema, java.lang.StringBuilder builder, int treeIndex)
private java.lang.String
admin()
private java.lang.String
adminLogin()
private java.lang.String
adminSave()
protected java.lang.String
adminShutdown()
Stop the application and the server.private java.lang.String
adminStartTranslate()
private java.lang.String
autoCompleteList()
private boolean
checkAdmin(java.lang.String file)
private java.lang.String
editResult()
private static java.lang.String
escapeData(java.sql.ResultSet rs, int columnIndex)
private static java.lang.String
escapeIdentifier(java.lang.String name)
private java.lang.String
executeLoop(java.sql.Connection conn, int count, java.lang.String sql)
private static java.lang.String
formatAsError(java.lang.String s)
(package private) boolean
getCache()
private static java.lang.String
getComboBox(java.lang.String[][] elements, java.lang.String selected)
private static java.lang.String
getComboBox(java.lang.String[] elements, java.lang.String selected)
private java.lang.String
getCommandHistoryString()
private java.lang.String
getHistory()
private java.lang.String
getLoginError(java.lang.Exception e, boolean isH2)
Get the formatted login error message.private int
getMaxrows()
(package private) java.lang.String
getMimeType()
Get the current mime type.private static java.lang.String
getParameterResultSet(java.sql.ParameterMetaData meta)
private java.lang.String
getResult(java.sql.Connection conn, int id, java.lang.String sql, boolean allowEdit, boolean forceEdit)
private java.lang.String
getResultSet(java.lang.String sql, java.sql.ResultSet rs, boolean metadata, boolean list, boolean edit, long time, boolean allowEdit)
(package private) WebSession
getSession()
private java.lang.String
getStackTrace(int id, java.lang.Throwable e, boolean isH2)
private java.lang.String
index()
private static java.lang.String
linkToSource(java.lang.String s)
private java.lang.String
login(NetworkConnectionInfo networkConnectionInfo)
private java.lang.String
logout()
private static java.sql.PreparedStatement
prepareViewDefinitionQuery(java.sql.Connection conn, DbContents contents)
private java.lang.String
process(java.lang.String file, NetworkConnectionInfo networkConnectionInfo)
(package private) java.lang.String
processRequest(java.lang.String file, NetworkConnectionInfo networkConnectionInfo)
Process an HTTP request.private java.lang.String
query()
(package private) void
query(java.sql.Connection conn, java.lang.String s, int i, int size, java.lang.StringBuilder buff)
Execute a query and append the result to the buffer.(package private) void
setSession(WebSession session, java.util.Properties attributes)
Set the web session and attributes.private java.lang.String
settingRemove()
private java.lang.String
settingSave()
Save the current connection settings to the properties file.private java.lang.String
tables()
private java.lang.String
test(NetworkConnectionInfo networkConnectionInfo)
private java.lang.String
tools()
private void
trace(java.lang.String s)
private void
unescapeData(java.lang.String x, java.sql.ResultSet rs, int columnIndex)
-
-
-
Field Detail
-
SYSTEM_SCHEMA_COMPARATOR
private static final java.util.Comparator<DbTableOrView> SYSTEM_SCHEMA_COMPARATOR
-
server
protected final WebServer server
The web server.
-
session
protected WebSession session
The session.
-
attributes
protected java.util.Properties attributes
The session attributes
-
mimeType
protected java.lang.String mimeType
The mime type of the current response.
-
cache
protected boolean cache
Whether the response can be cached.
-
stop
protected boolean stop
Whether to close the connection.
-
headerLanguage
protected java.lang.String headerLanguage
The language in the HTTP header.
-
profiler
private Profiler profiler
-
-
Constructor Detail
-
WebApp
WebApp(WebServer server)
-
-
Method Detail
-
setSession
void setSession(WebSession session, java.util.Properties attributes)
Set the web session and attributes.- Parameters:
session
- the sessionattributes
- the attributes
-
processRequest
java.lang.String processRequest(java.lang.String file, NetworkConnectionInfo networkConnectionInfo)
Process an HTTP request.- Parameters:
file
- the file that was requestednetworkConnectionInfo
- the network connection information- Returns:
- the name of the file to return to the client
-
getComboBox
private static java.lang.String getComboBox(java.lang.String[] elements, java.lang.String selected)
-
getComboBox
private static java.lang.String getComboBox(java.lang.String[][] elements, java.lang.String selected)
-
process
private java.lang.String process(java.lang.String file, NetworkConnectionInfo networkConnectionInfo)
-
checkAdmin
private boolean checkAdmin(java.lang.String file)
-
adminLogin
private java.lang.String adminLogin()
-
autoCompleteList
private java.lang.String autoCompleteList()
-
admin
private java.lang.String admin()
-
adminSave
private java.lang.String adminSave()
-
tools
private java.lang.String tools()
-
adminStartTranslate
private java.lang.String adminStartTranslate()
-
adminShutdown
protected java.lang.String adminShutdown()
Stop the application and the server.- Returns:
- the page to display
-
index
private java.lang.String index()
-
getHistory
private java.lang.String getHistory()
-
addColumns
private static int addColumns(boolean mainSchema, DbTableOrView table, java.lang.StringBuilder builder, int treeIndex, boolean showColumnTypes, java.lang.StringBuilder columnsBuilder)
-
escapeIdentifier
private static java.lang.String escapeIdentifier(java.lang.String name)
-
addIndexes
private static int addIndexes(boolean mainSchema, java.sql.DatabaseMetaData meta, java.lang.String table, java.lang.String schema, java.lang.StringBuilder buff, int treeIndex) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
addTablesAndViews
private int addTablesAndViews(DbSchema schema, boolean mainSchema, java.lang.StringBuilder builder, int treeIndex) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
prepareViewDefinitionQuery
private static java.sql.PreparedStatement prepareViewDefinitionQuery(java.sql.Connection conn, DbContents contents)
-
addTableOrView
private static int addTableOrView(DbSchema schema, boolean mainSchema, java.lang.StringBuilder builder, int treeIndex, java.sql.DatabaseMetaData meta, boolean showColumns, java.lang.String indentation, boolean isOracle, boolean notManyTables, DbTableOrView table, boolean isView, java.sql.PreparedStatement prep, java.lang.String indentNode) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
tables
private java.lang.String tables()
-
getStackTrace
private java.lang.String getStackTrace(int id, java.lang.Throwable e, boolean isH2)
-
linkToSource
private static java.lang.String linkToSource(java.lang.String s)
-
formatAsError
private static java.lang.String formatAsError(java.lang.String s)
-
test
private java.lang.String test(NetworkConnectionInfo networkConnectionInfo)
-
getLoginError
private java.lang.String getLoginError(java.lang.Exception e, boolean isH2)
Get the formatted login error message.- Parameters:
e
- the exceptionisH2
- if the current database is a H2 database- Returns:
- the formatted error message
-
login
private java.lang.String login(NetworkConnectionInfo networkConnectionInfo)
-
logout
private java.lang.String logout()
-
query
private java.lang.String query()
-
query
void query(java.sql.Connection conn, java.lang.String s, int i, int size, java.lang.StringBuilder buff)
Execute a query and append the result to the buffer.- Parameters:
conn
- the connections
- the statementi
- the indexsize
- the number of statementsbuff
- the target buffer
-
editResult
private java.lang.String editResult()
-
getMaxrows
private int getMaxrows()
-
getResult
private java.lang.String getResult(java.sql.Connection conn, int id, java.lang.String sql, boolean allowEdit, boolean forceEdit)
-
executeLoop
private java.lang.String executeLoop(java.sql.Connection conn, int count, java.lang.String sql) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
getCommandHistoryString
private java.lang.String getCommandHistoryString()
-
getParameterResultSet
private static java.lang.String getParameterResultSet(java.sql.ParameterMetaData meta) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
getResultSet
private java.lang.String getResultSet(java.lang.String sql, java.sql.ResultSet rs, boolean metadata, boolean list, boolean edit, long time, boolean allowEdit) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
settingSave
private java.lang.String settingSave()
Save the current connection settings to the properties file.- Returns:
- the file to open afterwards
-
escapeData
private static java.lang.String escapeData(java.sql.ResultSet rs, int columnIndex) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
unescapeData
private void unescapeData(java.lang.String x, java.sql.ResultSet rs, int columnIndex) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
settingRemove
private java.lang.String settingRemove()
-
getMimeType
java.lang.String getMimeType()
Get the current mime type.- Returns:
- the mime type
-
getCache
boolean getCache()
-
getSession
WebSession getSession()
-
trace
private void trace(java.lang.String s)
-
-