use of org.parosproxy.paros.db.DatabaseException in project zaproxy by zaproxy.
the class ExtensionAlert method deleteAllAlerts.
public void deleteAllAlerts() {
try {
getModel().getDb().getTableAlert().deleteAllAlerts();
} catch (DatabaseException e) {
logger.error(e.getMessage(), e);
}
SiteMap siteTree = this.getModel().getSession().getSiteTree();
((SiteNode) siteTree.getRoot()).deleteAllAlerts();
for (HistoryReference href : hrefs.values()) {
href.deleteAllAlerts();
}
ZAP.getEventBus().publishSyncEvent(AlertEventPublisher.getPublisher(), new Event(AlertEventPublisher.getPublisher(), AlertEventPublisher.ALL_ALERTS_REMOVED_EVENT, null));
hrefs = new HashMap<>();
treeModel = null;
filteredTreeModel = null;
setTreeModel(getTreeModel());
}
use of org.parosproxy.paros.db.DatabaseException in project zaproxy by zaproxy.
the class SqlTableSession method listSessions.
@Override
public List<RecordSession> listSessions() throws DatabaseException {
SqlPreparedStatementWrapper psList = null;
try {
psList = DbSQL.getSingleton().getPreparedStatement("session.ps.list");
List<RecordSession> result = new ArrayList<RecordSession>();
try (ResultSet rs = psList.getPs().executeQuery()) {
RecordSession ra = build(rs);
while (ra != null) {
result.add(ra);
ra = build(rs);
}
}
return result;
} catch (SQLException e) {
throw new DatabaseException(e);
} finally {
DbSQL.getSingleton().releasePreparedStatement(psList);
}
}
use of org.parosproxy.paros.db.DatabaseException in project zaproxy by zaproxy.
the class SqlTableSessionUrl method deleteAllUrlsForType.
/* (non-Javadoc)
* @see org.parosproxy.paros.db.paros.TableSessionUrl#deleteAllUrlsForType(int)
*/
@Override
public synchronized void deleteAllUrlsForType(int type) throws DatabaseException {
SqlPreparedStatementWrapper psDeleteAllUrlsForType = null;
try {
psDeleteAllUrlsForType = DbSQL.getSingleton().getPreparedStatement("sessionurl.ps.deleteurlsfortype");
psDeleteAllUrlsForType.getPs().setInt(1, type);
psDeleteAllUrlsForType.getPs().executeUpdate();
} catch (SQLException e) {
throw new DatabaseException(e);
} finally {
DbSQL.getSingleton().releasePreparedStatement(psDeleteAllUrlsForType);
}
}
use of org.parosproxy.paros.db.DatabaseException in project zaproxy by zaproxy.
the class SqlTableSessionUrl method delete.
/* (non-Javadoc)
* @see org.parosproxy.paros.db.paros.TableSessionUrl#delete(int, java.lang.String)
*/
@Override
public synchronized void delete(int type, String url) throws DatabaseException {
SqlPreparedStatementWrapper psDeleteUrls = null;
try {
psDeleteUrls = DbSQL.getSingleton().getPreparedStatement("sessionurl.ps.deleteurls");
psDeleteUrls.getPs().setInt(1, type);
psDeleteUrls.getPs().setString(2, url);
psDeleteUrls.getPs().executeUpdate();
} catch (SQLException e) {
throw new DatabaseException(e);
} finally {
DbSQL.getSingleton().releasePreparedStatement(psDeleteUrls);
}
}
use of org.parosproxy.paros.db.DatabaseException in project zaproxy by zaproxy.
the class SqlTableSessionUrl method getUrlsForType.
/* (non-Javadoc)
* @see org.parosproxy.paros.db.paros.TableSessionUrl#getUrlsForType(int)
*/
@Override
public List<RecordSessionUrl> getUrlsForType(int type) throws DatabaseException {
SqlPreparedStatementWrapper psGetAlluRLSForType = null;
try {
psGetAlluRLSForType = DbSQL.getSingleton().getPreparedStatement("sessionurl.ps.geturlsfortype");
psGetAlluRLSForType.getPs().setInt(1, type);
try (ResultSet rs = psGetAlluRLSForType.getPs().executeQuery()) {
List<RecordSessionUrl> result = new ArrayList<>();
while (rs.next()) {
result.add(new RecordSessionUrl(rs.getLong(URLID), rs.getInt(TYPE), rs.getString(URL)));
}
return result;
}
} catch (SQLException e) {
throw new DatabaseException(e);
} finally {
DbSQL.getSingleton().releasePreparedStatement(psGetAlluRLSForType);
}
}
Aggregations