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 {
private static boolean scrollResultsSupported;
// True if the database supports batch updates.
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;
......@@ -692,8 +688,6 @@ public class DbConnectionManager {
streamTextRequired = false;
maxRowsSupported = true;
fetchSizeSupported = true;
dualTableSupported = false;
selectRequiresFrom = false;
// Get the database name so that we can perform meta data settings.
String dbName = metaData.getDatabaseProductName().toLowerCase();
......@@ -704,8 +698,6 @@ public class DbConnectionManager {
databaseType = DatabaseType.oracle;
streamTextRequired = true;
scrollResultsSupported = false;
dualTableSupported = true;
selectRequiresFrom = true;
// The i-net AUGURO JDBC driver
if (driverName.indexOf("auguro") != -1) {
streamTextRequired = false;
......@@ -739,7 +731,6 @@ public class DbConnectionManager {
else if (dbName.indexOf("mysql") != -1) {
databaseType = DatabaseType.mysql;
transactionsSupported = false;
dualTableSupported = true;
}
// HSQL properties
else if (dbName.indexOf("hsql") != -1) {
......@@ -821,16 +812,23 @@ public class DbConnectionManager {
return batchUpdatesSupported;
}
public static boolean isDualTableSupported() {
return dualTableSupported;
public static boolean isEmbeddedDB() {
return connectionProvider != null && connectionProvider instanceof EmbeddedConnectionProvider;
}
public static boolean doesSelectRequireFrom() {
return selectRequiresFrom;
public static String getTestSQL(String driver) {
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 {
*/
private void loadProperties() {
String defTestSQL = "select 1";
if (DbConnectionManager.isDualTableSupported() && DbConnectionManager.doesSelectRequireFrom()) {
defTestSQL = defTestSQL + " from dual";
}
driver = JiveGlobals.getXMLProperty("database.defaultProvider.driver");
serverURL = JiveGlobals.getXMLProperty("database.defaultProvider.serverURL");
username = JiveGlobals.getXMLProperty("database.defaultProvider.username");
......@@ -334,7 +329,7 @@ public class DefaultConnectionProvider implements ConnectionProvider {
String minCons = JiveGlobals.getXMLProperty("database.defaultProvider.minConnections");
String maxCons = JiveGlobals.getXMLProperty("database.defaultProvider.maxConnections");
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);
testAfterUse = JiveGlobals.getXMLProperty("database.defaultProvider.testAfterUse", true);
......
......@@ -25,6 +25,7 @@ import org.jivesoftware.openfire.user.UserNotFoundException;
import org.jivesoftware.util.Log;
import org.xmpp.packet.JID;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
......@@ -323,7 +324,7 @@ public class ClearspaceGroupProvider implements GroupProvider {
private Element getGroupByName(String name) throws GroupNotFoundException {
try {
String path = URL_PREFIX + "groups/" + name;
String path = URL_PREFIX + "groups/" + URLEncoder.encode(name, "UTF-8");
return ClearspaceManager.getInstance().executeRequest(GET, path);
} catch (GroupNotFoundException gnfe) {
......
......@@ -107,8 +107,8 @@ public class DefaultLockOutProvider implements LockOutProvider {
else {
pstmt.setNull(2, Types.VARCHAR);
}
if (flag.getStartTime() != null) {
pstmt.setString(3, StringUtils.dateToMillis(flag.getStartTime()));
if (flag.getEndTime() != null) {
pstmt.setString(3, StringUtils.dateToMillis(flag.getEndTime()));
}
else {
pstmt.setNull(3, Types.VARCHAR);
......
......@@ -13,6 +13,7 @@ import org.jivesoftware.database.SequenceManager;
import org.jivesoftware.database.DbConnectionManager;
import org.jivesoftware.util.JiveConstants;
import org.jivesoftware.util.Log;
import org.jivesoftware.util.StringUtils;
import org.jivesoftware.openfire.XMPPServer;
import java.util.List;
......@@ -28,7 +29,7 @@ import java.sql.*;
public class DefaultSecurityAuditProvider implements SecurityAuditProvider {
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 =
"SELECT msgID,username,entryStamp,summary,node,details FROM ofSecurityAuditLog";
private static final String GET_EVENT =
......@@ -57,7 +58,7 @@ public class DefaultSecurityAuditProvider implements SecurityAuditProvider {
pstmt.setLong(1, msgID);
pstmt.setString(2, username);
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(6, details);
pstmt.executeUpdate();
......
......@@ -37,7 +37,7 @@
TimeZone tz = TimeZone.getTimeZone(timeZoneID);
JiveGlobals.setTimeZone(tz);
// Log the event
webManager.logEvent("updated time zone to "+tz, null);
webManager.logEvent("updated time zone to "+tz.getID(), tz.toString());
}
catch (Exception e) {
Log.error(e);
......@@ -50,7 +50,7 @@
else {
JiveGlobals.setLocale(newLocale);
// 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");
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