Search in sources :

Example 1 with Banlist

use of net.jforum.entities.Banlist in project jforum2 by rafaelsteil.

the class JForum method shouldBan.

private boolean shouldBan(String ip) {
    Banlist b = new Banlist();
    b.setUserId(SessionFacade.getUserSession().getUserId());
    b.setIp(ip);
    return BanlistRepository.shouldBan(b);
}
Also used : Banlist(net.jforum.entities.Banlist)

Example 2 with Banlist

use of net.jforum.entities.Banlist in project jforum2 by rafaelsteil.

the class BanlistAction method insertSave.

public void insertSave() {
    String type = this.request.getParameter("type");
    String value = this.request.getParameter("value");
    if (!StringUtils.isEmpty(type) && !StringUtils.isEmpty(value)) {
        Banlist b = new Banlist();
        if ("email".equals(type)) {
            b.setEmail(value);
        } else if ("user".equals(type)) {
            b.setUserId(Integer.parseInt(value));
        } else if ("ip".equals(type)) {
            b.setIp(value);
        } else {
            throw new ForumException("Unknown banlist type");
        }
        BanlistDAO dao = DataAccessDriver.getInstance().newBanlistDAO();
        dao.insert(b);
        BanlistRepository.add(b);
    }
    this.list();
}
Also used : ForumException(net.jforum.exceptions.ForumException) BanlistDAO(net.jforum.dao.BanlistDAO) Banlist(net.jforum.entities.Banlist)

Example 3 with Banlist

use of net.jforum.entities.Banlist in project jforum2 by rafaelsteil.

the class GenericBanlistDAO method selectAll.

/**
 * @see net.jforum.dao.BanlistDAO#selectAll()
 */
public List selectAll() {
    ResultSet rs = null;
    PreparedStatement p = null;
    List l = new ArrayList();
    try {
        p = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("BanlistModel.selectAll"));
        rs = p.executeQuery();
        while (rs.next()) {
            Banlist b = new Banlist();
            b.setId(rs.getInt("banlist_id"));
            b.setUserId(rs.getInt("user_id"));
            b.setEmail(rs.getString("banlist_email"));
            b.setIp(rs.getString("banlist_ip"));
            l.add(b);
        }
    } catch (Exception e) {
        throw new DatabaseException(e);
    } finally {
        DbUtils.close(rs, p);
    }
    return l;
}
Also used : ResultSet(java.sql.ResultSet) ArrayList(java.util.ArrayList) PreparedStatement(java.sql.PreparedStatement) List(java.util.List) ArrayList(java.util.ArrayList) DatabaseException(net.jforum.exceptions.DatabaseException) DatabaseException(net.jforum.exceptions.DatabaseException) Banlist(net.jforum.entities.Banlist)

Aggregations

Banlist (net.jforum.entities.Banlist)3 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 BanlistDAO (net.jforum.dao.BanlistDAO)1 DatabaseException (net.jforum.exceptions.DatabaseException)1 ForumException (net.jforum.exceptions.ForumException)1