Commit 19c9edd1 authored by Daniel Henninger's avatar Daniel Henninger Committed by dhenninger

Ported changes from branch.

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@10194 b35dd754-fafc-0310-a699-88a17e54d16e
parent 571c5376
...@@ -51,10 +51,6 @@ public class DbConnectionManager { ...@@ -51,10 +51,6 @@ public class DbConnectionManager {
private static boolean scrollResultsSupported; private static boolean scrollResultsSupported;
// True if the database supports batch updates. // True if the database supports batch updates.
private static boolean batchUpdatesSupported; private static boolean batchUpdatesSupported;
// True if the database supports the dual table.
private static boolean dualTableSupported;
// True if the database does not support select without from.
private static boolean selectRequiresFrom;
private static DatabaseType databaseType = DatabaseType.unknown; private static DatabaseType databaseType = DatabaseType.unknown;
...@@ -692,8 +688,6 @@ public class DbConnectionManager { ...@@ -692,8 +688,6 @@ public class DbConnectionManager {
streamTextRequired = false; streamTextRequired = false;
maxRowsSupported = true; maxRowsSupported = true;
fetchSizeSupported = true; fetchSizeSupported = true;
dualTableSupported = false;
selectRequiresFrom = false;
// Get the database name so that we can perform meta data settings. // Get the database name so that we can perform meta data settings.
String dbName = metaData.getDatabaseProductName().toLowerCase(); String dbName = metaData.getDatabaseProductName().toLowerCase();
...@@ -704,8 +698,6 @@ public class DbConnectionManager { ...@@ -704,8 +698,6 @@ public class DbConnectionManager {
databaseType = DatabaseType.oracle; databaseType = DatabaseType.oracle;
streamTextRequired = true; streamTextRequired = true;
scrollResultsSupported = false; scrollResultsSupported = false;
dualTableSupported = true;
selectRequiresFrom = true;
// The i-net AUGURO JDBC driver // The i-net AUGURO JDBC driver
if (driverName.indexOf("auguro") != -1) { if (driverName.indexOf("auguro") != -1) {
streamTextRequired = false; streamTextRequired = false;
...@@ -739,7 +731,6 @@ public class DbConnectionManager { ...@@ -739,7 +731,6 @@ public class DbConnectionManager {
else if (dbName.indexOf("mysql") != -1) { else if (dbName.indexOf("mysql") != -1) {
databaseType = DatabaseType.mysql; databaseType = DatabaseType.mysql;
transactionsSupported = false; transactionsSupported = false;
dualTableSupported = true;
} }
// HSQL properties // HSQL properties
else if (dbName.indexOf("hsql") != -1) { else if (dbName.indexOf("hsql") != -1) {
...@@ -821,16 +812,23 @@ public class DbConnectionManager { ...@@ -821,16 +812,23 @@ public class DbConnectionManager {
return batchUpdatesSupported; return batchUpdatesSupported;
} }
public static boolean isDualTableSupported() { public static boolean isEmbeddedDB() {
return dualTableSupported; return connectionProvider != null && connectionProvider instanceof EmbeddedConnectionProvider;
} }
public static boolean doesSelectRequireFrom() { public static String getTestSQL(String driver) {
return selectRequiresFrom; if (driver == null) {
return "select 1";
}
else if (driver.contains("db2")) {
return "select 1 from sysibm.sysdummy1";
}
else if (driver.contains("oracle")) {
return "select 1 from dual";
}
else {
return "select 1";
} }
public static boolean isEmbeddedDB() {
return connectionProvider != null && connectionProvider instanceof EmbeddedConnectionProvider;
} }
/** /**
......
...@@ -322,11 +322,6 @@ public class DefaultConnectionProvider implements ConnectionProvider { ...@@ -322,11 +322,6 @@ public class DefaultConnectionProvider implements ConnectionProvider {
*/ */
private void loadProperties() { private void loadProperties() {
String defTestSQL = "select 1";
if (DbConnectionManager.isDualTableSupported() && DbConnectionManager.doesSelectRequireFrom()) {
defTestSQL = defTestSQL + " from dual";
}
driver = JiveGlobals.getXMLProperty("database.defaultProvider.driver"); driver = JiveGlobals.getXMLProperty("database.defaultProvider.driver");
serverURL = JiveGlobals.getXMLProperty("database.defaultProvider.serverURL"); serverURL = JiveGlobals.getXMLProperty("database.defaultProvider.serverURL");
username = JiveGlobals.getXMLProperty("database.defaultProvider.username"); username = JiveGlobals.getXMLProperty("database.defaultProvider.username");
...@@ -334,7 +329,7 @@ public class DefaultConnectionProvider implements ConnectionProvider { ...@@ -334,7 +329,7 @@ public class DefaultConnectionProvider implements ConnectionProvider {
String minCons = JiveGlobals.getXMLProperty("database.defaultProvider.minConnections"); String minCons = JiveGlobals.getXMLProperty("database.defaultProvider.minConnections");
String maxCons = JiveGlobals.getXMLProperty("database.defaultProvider.maxConnections"); String maxCons = JiveGlobals.getXMLProperty("database.defaultProvider.maxConnections");
String conTimeout = JiveGlobals.getXMLProperty("database.defaultProvider.connectionTimeout"); String conTimeout = JiveGlobals.getXMLProperty("database.defaultProvider.connectionTimeout");
testSQL = JiveGlobals.getXMLProperty("database.defaultProvider.testSQL", defTestSQL); testSQL = JiveGlobals.getXMLProperty("database.defaultProvider.testSQL", DbConnectionManager.getTestSQL(driver));
testBeforeUse = JiveGlobals.getXMLProperty("database.defaultProvider.testBeforeUse", true); testBeforeUse = JiveGlobals.getXMLProperty("database.defaultProvider.testBeforeUse", true);
testAfterUse = JiveGlobals.getXMLProperty("database.defaultProvider.testAfterUse", true); testAfterUse = JiveGlobals.getXMLProperty("database.defaultProvider.testAfterUse", true);
......
...@@ -25,6 +25,7 @@ import org.jivesoftware.openfire.user.UserNotFoundException; ...@@ -25,6 +25,7 @@ import org.jivesoftware.openfire.user.UserNotFoundException;
import org.jivesoftware.util.Log; import org.jivesoftware.util.Log;
import org.xmpp.packet.JID; import org.xmpp.packet.JID;
import java.net.URLEncoder;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
...@@ -323,7 +324,7 @@ public class ClearspaceGroupProvider implements GroupProvider { ...@@ -323,7 +324,7 @@ public class ClearspaceGroupProvider implements GroupProvider {
private Element getGroupByName(String name) throws GroupNotFoundException { private Element getGroupByName(String name) throws GroupNotFoundException {
try { try {
String path = URL_PREFIX + "groups/" + name; String path = URL_PREFIX + "groups/" + URLEncoder.encode(name, "UTF-8");
return ClearspaceManager.getInstance().executeRequest(GET, path); return ClearspaceManager.getInstance().executeRequest(GET, path);
} catch (GroupNotFoundException gnfe) { } catch (GroupNotFoundException gnfe) {
......
...@@ -107,8 +107,8 @@ public class DefaultLockOutProvider implements LockOutProvider { ...@@ -107,8 +107,8 @@ public class DefaultLockOutProvider implements LockOutProvider {
else { else {
pstmt.setNull(2, Types.VARCHAR); pstmt.setNull(2, Types.VARCHAR);
} }
if (flag.getStartTime() != null) { if (flag.getEndTime() != null) {
pstmt.setString(3, StringUtils.dateToMillis(flag.getStartTime())); pstmt.setString(3, StringUtils.dateToMillis(flag.getEndTime()));
} }
else { else {
pstmt.setNull(3, Types.VARCHAR); pstmt.setNull(3, Types.VARCHAR);
......
...@@ -13,6 +13,7 @@ import org.jivesoftware.database.SequenceManager; ...@@ -13,6 +13,7 @@ import org.jivesoftware.database.SequenceManager;
import org.jivesoftware.database.DbConnectionManager; import org.jivesoftware.database.DbConnectionManager;
import org.jivesoftware.util.JiveConstants; import org.jivesoftware.util.JiveConstants;
import org.jivesoftware.util.Log; import org.jivesoftware.util.Log;
import org.jivesoftware.util.StringUtils;
import org.jivesoftware.openfire.XMPPServer; import org.jivesoftware.openfire.XMPPServer;
import java.util.List; import java.util.List;
...@@ -28,7 +29,7 @@ import java.sql.*; ...@@ -28,7 +29,7 @@ import java.sql.*;
public class DefaultSecurityAuditProvider implements SecurityAuditProvider { public class DefaultSecurityAuditProvider implements SecurityAuditProvider {
private static final String LOG_ENTRY = private static final String LOG_ENTRY =
"INSERT INTO ofSecurityAuditLog VALUES(?,?,?,?,?,?)"; "INSERT INTO ofSecurityAuditLog(msgID,username,entryStamp,summary,node,details) VALUES(?,?,?,?,?,?)";
private static final String GET_EVENTS = private static final String GET_EVENTS =
"SELECT msgID,username,entryStamp,summary,node,details FROM ofSecurityAuditLog"; "SELECT msgID,username,entryStamp,summary,node,details FROM ofSecurityAuditLog";
private static final String GET_EVENT = private static final String GET_EVENT =
...@@ -57,7 +58,7 @@ public class DefaultSecurityAuditProvider implements SecurityAuditProvider { ...@@ -57,7 +58,7 @@ public class DefaultSecurityAuditProvider implements SecurityAuditProvider {
pstmt.setLong(1, msgID); pstmt.setLong(1, msgID);
pstmt.setString(2, username); pstmt.setString(2, username);
pstmt.setLong(3, new Date().getTime()); pstmt.setLong(3, new Date().getTime());
pstmt.setString(4, summary); pstmt.setString(4, StringUtils.abbreviate(summary, 250));
pstmt.setString(5, XMPPServer.getInstance().getServerInfo().getHostname()); pstmt.setString(5, XMPPServer.getInstance().getServerInfo().getHostname());
pstmt.setString(6, details); pstmt.setString(6, details);
pstmt.executeUpdate(); pstmt.executeUpdate();
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
TimeZone tz = TimeZone.getTimeZone(timeZoneID); TimeZone tz = TimeZone.getTimeZone(timeZoneID);
JiveGlobals.setTimeZone(tz); JiveGlobals.setTimeZone(tz);
// Log the event // Log the event
webManager.logEvent("updated time zone to "+tz, null); webManager.logEvent("updated time zone to "+tz.getID(), tz.toString());
} }
catch (Exception e) { catch (Exception e) {
Log.error(e); Log.error(e);
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
else { else {
JiveGlobals.setLocale(newLocale); JiveGlobals.setLocale(newLocale);
// Log the event // Log the event
webManager.logEvent("updated locale to "+newLocale, null); webManager.logEvent("updated locale to "+newLocale.getDisplayName(), null);
response.sendRedirect("server-locale.jsp?success=true"); response.sendRedirect("server-locale.jsp?success=true");
return; return;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment