Search in sources :

Example 1 with RecordParam

use of org.parosproxy.paros.db.RecordParam in project zaproxy by zaproxy.

the class ExtensionParams method persist.

private void persist(HtmlParameterStats param) {
    try {
        if (param.getId() < 0) {
            // Its a new one
            RecordParam rp = Model.getSingleton().getDb().getTableParam().insert(param.getSite(), param.getType().name(), param.getName(), param.getTimesUsed(), setToString(param.getFlags()), setToString(param.getValues()));
            param.setId(rp.getParamId());
        } else {
            // Its an existing one
            Model.getSingleton().getDb().getTableParam().update(param.getId(), param.getTimesUsed(), setToString(param.getFlags()), setToString(param.getValues()));
        }
    } catch (DatabaseException e) {
        logger.error(e.getMessage(), e);
    }
}
Also used : RecordParam(org.parosproxy.paros.db.RecordParam) DatabaseException(org.parosproxy.paros.db.DatabaseException)

Example 2 with RecordParam

use of org.parosproxy.paros.db.RecordParam in project zaproxy by zaproxy.

the class ExtensionParams method sessionChangedEventHandler.

private void sessionChangedEventHandler(Session session) {
    // Clear all scans
    siteParamsMap = new HashMap<>();
    if (getView() != null) {
        this.getParamsPanel().reset();
    }
    if (session == null) {
        // Closedown
        return;
    }
    // Repopulate
    SiteNode root = (SiteNode) session.getSiteTree().getRoot();
    @SuppressWarnings("unchecked") Enumeration<SiteNode> en = root.children();
    while (en.hasMoreElements()) {
        String site = en.nextElement().getNodeName();
        if (site.indexOf("//") >= 0) {
            site = site.substring(site.indexOf("//") + 2);
        }
        if (getView() != null) {
            this.getParamsPanel().addSite(site);
        }
    }
    try {
        List<RecordParam> params = Model.getSingleton().getDb().getTableParam().getAll();
        for (RecordParam param : params) {
            SiteParameters sps = this.getSiteParameters(param.getSite());
            sps.addParam(param.getSite(), param);
        }
    } catch (DatabaseException e) {
        logger.error(e.getMessage(), e);
    }
}
Also used : RecordParam(org.parosproxy.paros.db.RecordParam) DatabaseException(org.parosproxy.paros.db.DatabaseException) SiteNode(org.parosproxy.paros.model.SiteNode)

Example 3 with RecordParam

use of org.parosproxy.paros.db.RecordParam in project zaproxy by zaproxy.

the class SqlTableParam method read.

/* (non-Javadoc)
	 * @see org.parosproxy.paros.db.paros.TableParam#read(long)
	 */
@Override
public synchronized RecordParam read(long urlId) throws DatabaseException {
    SqlPreparedStatementWrapper psRead = null;
    try {
        psRead = DbSQL.getSingleton().getPreparedStatement("param.ps.read");
        psRead.getPs().setLong(1, urlId);
        try (ResultSet rs = psRead.getPs().executeQuery()) {
            RecordParam result = build(rs);
            return result;
        }
    } catch (SQLException e) {
        throw new DatabaseException(e);
    } finally {
        DbSQL.getSingleton().releasePreparedStatement(psRead);
    }
}
Also used : SQLException(java.sql.SQLException) ResultSet(java.sql.ResultSet) RecordParam(org.parosproxy.paros.db.RecordParam) DatabaseException(org.parosproxy.paros.db.DatabaseException)

Example 4 with RecordParam

use of org.parosproxy.paros.db.RecordParam in project zaproxy by zaproxy.

the class SqlTableParam method getAll.

/* (non-Javadoc)
	 * @see org.parosproxy.paros.db.paros.TableParam#getAll()
	 */
@Override
public List<RecordParam> getAll() throws DatabaseException {
    SqlPreparedStatementWrapper psGetAll = null;
    try {
        psGetAll = DbSQL.getSingleton().getPreparedStatement("param.ps.getall");
        List<RecordParam> result = new ArrayList<>();
        try (ResultSet rs = psGetAll.getPs().executeQuery()) {
            while (rs.next()) {
                result.add(new RecordParam(rs.getLong(PARAMID), rs.getString(SITE), rs.getString(TYPE), rs.getString(NAME), rs.getInt(USED), rs.getString(FLAGS), rs.getString(VALUES)));
            }
        }
        return result;
    } catch (SQLException e) {
        throw new DatabaseException(e);
    } finally {
        DbSQL.getSingleton().releasePreparedStatement(psGetAll);
    }
}
Also used : SQLException(java.sql.SQLException) ArrayList(java.util.ArrayList) RecordParam(org.parosproxy.paros.db.RecordParam) ResultSet(java.sql.ResultSet) DatabaseException(org.parosproxy.paros.db.DatabaseException)

Aggregations

DatabaseException (org.parosproxy.paros.db.DatabaseException)4 RecordParam (org.parosproxy.paros.db.RecordParam)4 ResultSet (java.sql.ResultSet)2 SQLException (java.sql.SQLException)2 ArrayList (java.util.ArrayList)1 SiteNode (org.parosproxy.paros.model.SiteNode)1