Search in sources :

Example 66 with DatabaseException

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

the class SearchAPI method search.

private void search(JSONObject params, ExtensionSearch.Type searchType, SearchResultsProcessor processor) throws InterruptedException {
    ApiSearchListener searchListener = new ApiSearchListener();
    // The search kicks off a background thread
    extension.search(params.getString(PARAM_REGEX), searchListener, searchType, false, false, this.getParam(params, PARAM_BASE_URL, (String) null), this.getParam(params, PARAM_START, -1), this.getParam(params, PARAM_COUNT, -1), false);
    while (!searchListener.isSearchComplete()) {
        Thread.sleep(100);
    }
    TableHistory tableHistory = Model.getSingleton().getDb().getTableHistory();
    for (Integer hRefId : searchListener.getHistoryReferencesIds()) {
        try {
            processor.processRecordHistory(tableHistory.read(hRefId.intValue()));
        } catch (DatabaseException | HttpMalformedHeaderException e) {
            log.error(e.getMessage(), e);
        }
    }
}
Also used : HttpMalformedHeaderException(org.parosproxy.paros.network.HttpMalformedHeaderException) TableHistory(org.parosproxy.paros.db.TableHistory) DatabaseException(org.parosproxy.paros.db.DatabaseException)

Example 67 with DatabaseException

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

the class ExtensionHistory method searchHistory.

private void searchHistory(HistoryFilter historyFilter) {
    Session session = getModel().getSession();
    synchronized (historyTableModel) {
        try {
            // ZAP: Added type argument.
            List<Integer> list = getModel().getDb().getTableHistory().getHistoryIdsOfHistType(session.getSessionId(), HistoryReference.TYPE_PROXIED, HistoryReference.TYPE_ZAP_USER, HistoryReference.TYPE_PROXY_CONNECT);
            buildHistory(list, historyFilter);
        } catch (DatabaseException e) {
            logger.error(e.getMessage(), e);
        }
    }
}
Also used : DatabaseException(org.parosproxy.paros.db.DatabaseException) Session(org.parosproxy.paros.model.Session)

Example 68 with DatabaseException

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

the class ExtensionHistory method showFilterPlusDialog.

protected int showFilterPlusDialog() {
    HistoryFilterPlusDialog dialog = getFilterPlusDialog();
    dialog.setModal(true);
    try {
        dialog.setAllTags(getModel().getDb().getTableTag().getAllTags());
    } catch (DatabaseException e) {
        logger.error(e.getMessage(), e);
    }
    int exit = dialog.showDialog();
    // cancel, state unchanged
    int result = 0;
    HistoryFilter historyFilter = dialog.getFilter();
    if (exit == JOptionPane.OK_OPTION) {
        searchHistory(historyFilter);
        logPanel.setFilterStatus(historyFilter);
        // applied
        result = 1;
    } else if (exit == JOptionPane.NO_OPTION) {
        searchHistory(historyFilter);
        logPanel.setFilterStatus(historyFilter);
        // reset
        result = -1;
    }
    return result;
}
Also used : HistoryFilterPlusDialog(org.zaproxy.zap.extension.history.HistoryFilterPlusDialog) DatabaseException(org.parosproxy.paros.db.DatabaseException)

Example 69 with DatabaseException

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

the class ParosTableTag method delete.

/* (non-Javadoc)
	 * @see org.parosproxy.paros.db.paros.TableTag#delete(long, java.lang.String)
	 */
@Override
public synchronized void delete(long historyId, String tag) throws DatabaseException {
    try {
        psDeleteTag.setLong(1, historyId);
        psDeleteTag.setString(2, tag);
        psDeleteTag.executeUpdate();
    } catch (SQLException e) {
        throw new DatabaseException(e);
    }
}
Also used : SQLException(java.sql.SQLException) DatabaseException(org.parosproxy.paros.db.DatabaseException)

Example 70 with DatabaseException

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

the class ParosTableTag method deleteTagsForHistoryID.

/* (non-Javadoc)
	 * @see org.parosproxy.paros.db.paros.TableTag#deleteTagsForHistoryID(long)
	 */
@Override
public synchronized void deleteTagsForHistoryID(long historyId) throws DatabaseException {
    try {
        psDeleteTagsForHistoryId.setLong(1, historyId);
        psDeleteTagsForHistoryId.execute();
    } catch (SQLException e) {
        throw new DatabaseException(e);
    }
}
Also used : SQLException(java.sql.SQLException) 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