Search in sources :

Example 46 with DatabaseException

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());
}
Also used : HistoryReference(org.parosproxy.paros.model.HistoryReference) SiteMap(org.parosproxy.paros.model.SiteMap) Event(org.zaproxy.zap.eventBus.Event) DatabaseException(org.parosproxy.paros.db.DatabaseException) SiteNode(org.parosproxy.paros.model.SiteNode)

Example 47 with DatabaseException

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);
    }
}
Also used : SQLException(java.sql.SQLException) ArrayList(java.util.ArrayList) ResultSet(java.sql.ResultSet) RecordSession(org.parosproxy.paros.db.RecordSession) DatabaseException(org.parosproxy.paros.db.DatabaseException)

Example 48 with DatabaseException

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);
    }
}
Also used : SQLException(java.sql.SQLException) DatabaseException(org.parosproxy.paros.db.DatabaseException)

Example 49 with DatabaseException

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);
    }
}
Also used : SQLException(java.sql.SQLException) DatabaseException(org.parosproxy.paros.db.DatabaseException)

Example 50 with DatabaseException

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);
    }
}
Also used : RecordSessionUrl(org.parosproxy.paros.db.RecordSessionUrl) SQLException(java.sql.SQLException) ResultSet(java.sql.ResultSet) ArrayList(java.util.ArrayList) DatabaseException(org.parosproxy.paros.db.DatabaseException)

Aggregations

DatabaseException (org.parosproxy.paros.db.DatabaseException)153 SQLException (java.sql.SQLException)113 ResultSet (java.sql.ResultSet)61 ArrayList (java.util.ArrayList)28 HttpMalformedHeaderException (org.parosproxy.paros.network.HttpMalformedHeaderException)19 PreparedStatement (java.sql.PreparedStatement)11 Session (org.parosproxy.paros.model.Session)11 HttpMessage (org.parosproxy.paros.network.HttpMessage)11 RecordHistory (org.parosproxy.paros.db.RecordHistory)9 RecordAlert (org.parosproxy.paros.db.RecordAlert)7 RecordContext (org.parosproxy.paros.db.RecordContext)7 Vector (java.util.Vector)6 URIException (org.apache.commons.httpclient.URIException)6 IOException (java.io.IOException)5 TableHistory (org.parosproxy.paros.db.TableHistory)5 HistoryReference (org.parosproxy.paros.model.HistoryReference)5 StructuralSiteNode (org.zaproxy.zap.model.StructuralSiteNode)5 Matcher (java.util.regex.Matcher)4 PatternSyntaxException (java.util.regex.PatternSyntaxException)4 JSONException (net.sf.json.JSONException)4