use of net.jforum.exceptions.ForumException in project jforum2 by rafaelsteil.
the class SystemGlobals method loadQueries.
/**
* Load the SQL queries
*
* @param queryFile Complete path to the SQL queries file.
*/
public static void loadQueries(String queryFile) {
FileInputStream fis = null;
try {
fis = new FileInputStream(queryFile);
queries.load(fis);
} catch (IOException e) {
throw new ForumException(e);
} finally {
if (fis != null) {
try {
fis.close();
} catch (Exception e) {
}
}
}
}
use of net.jforum.exceptions.ForumException in project jforum2 by rafaelsteil.
the class SystemGlobals method loadDefaults.
/**
* Load system defaults
*/
public static void loadDefaults() {
try {
FileInputStream input = new FileInputStream(globals.defaultConfig);
globals.defaults.load(input);
input.close();
globals.expander.clearCache();
} catch (IOException e) {
throw new ForumException(e);
}
}
use of net.jforum.exceptions.ForumException in project jforum2 by rafaelsteil.
the class SystemGlobals method saveInstallation.
/**
* Save installation defaults
*/
public static void saveInstallation() {
// our new keys.
class SortedProperties extends Properties {
public synchronized Enumeration keys() {
Enumeration keysEnum = super.keys();
Vector keyList = new Vector();
while (keysEnum.hasMoreElements()) {
keyList.add(keysEnum.nextElement());
}
Collections.sort(keyList);
return keyList.elements();
}
}
Properties p = new SortedProperties();
p.putAll(globals.installation);
try {
FileOutputStream out = new FileOutputStream(globals.installationConfig);
p.store(out, "Installation specific configuration options");
out.close();
} catch (IOException e) {
throw new ForumException(e);
}
ConfigLoader.listenInstallationConfig();
}
use of net.jforum.exceptions.ForumException in project jforum2 by rafaelsteil.
the class DefaultLoginAuthenticator method validateLogin.
/**
* @see net.jforum.sso.LoginAuthenticator#validateLogin(String, String, java.util.Map)
*/
public User validateLogin(String username, String password, Map extraParams) {
User user = null;
ResultSet rs = null;
PreparedStatement p = null;
try {
p = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("UserModel.login"));
p.setString(1, username);
p.setString(2, MD5.crypt(password));
rs = p.executeQuery();
if (rs.next() && rs.getInt("user_id") > 0) {
user = this.userModel.selectById(rs.getInt("user_id"));
}
} catch (SQLException e) {
throw new ForumException(e);
} finally {
DbUtils.close(rs, p);
}
if (user != null && !user.isDeleted() && (user.getActivationKey() == null || user.isActive())) {
return user;
}
return null;
}
use of net.jforum.exceptions.ForumException in project jforum2 by rafaelsteil.
the class UploadUtils method saveUploadedFile.
public void saveUploadedFile(String filename) {
BufferedInputStream inputStream = null;
FileOutputStream outputStream = null;
try {
inputStream = new BufferedInputStream(this.item.getInputStream());
outputStream = new FileOutputStream(filename);
int c;
byte[] b = new byte[4096];
while ((c = inputStream.read(b)) != -1) {
outputStream.write(b, 0, c);
}
} catch (IOException e) {
throw new ForumException(e);
} finally {
if (outputStream != null) {
try {
outputStream.flush();
outputStream.close();
} catch (IOException e) {
}
}
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e) {
}
}
}
}
Aggregations