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);
}
}
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);
}
}
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);
}
}
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);
}
}
Aggregations