* @return true if database schema checked out fine, or was automatically installed
* or updated successfully, or if it isn't needed. False will only be returned
* if there is an error.
*/
public boolean checkPluginSchema(final Plugin plugin) {
final PluginManager pluginManager = XMPPServer.getInstance().getPluginManager();
String schemaKey = pluginManager.getDatabaseKey(plugin);
int schemaVersion = pluginManager.getDatabaseVersion(plugin);
// If the schema key or database version aren't defined, then the plugin doesn't
// need database tables.
if (schemaKey == null || schemaVersion == -1) {
return true;
}
Connection con = null;
try {
con = DbConnectionManager.getConnection();
return checkSchema(con, schemaKey, schemaVersion, new ResourceLoader() {
@Override
public InputStream loadResource(String resourceName) {
File file = new File(pluginManager.getPluginDirectory(plugin) +
File.separator + "database", resourceName);
try {
return new FileInputStream(file);
}
catch (FileNotFoundException e) {