Search in sources :

Example 1 with Event

use of org.zaproxy.zap.eventBus.Event 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 2 with Event

use of org.zaproxy.zap.eventBus.Event in project zaproxy by zaproxy.

the class ExtensionAlert method publishAlertEvent.

private void publishAlertEvent(Alert alert, String event) {
    HistoryReference historyReference = hrefs.get(alert.getSourceHistoryId());
    if (historyReference == null) {
        historyReference = Control.getSingleton().getExtensionLoader().getExtension(ExtensionHistory.class).getHistoryReference(alert.getSourceHistoryId());
    }
    Map<String, String> map = new HashMap<>();
    map.put(AlertEventPublisher.ALERT_ID, Integer.toString(alert.getAlertId()));
    map.put(AlertEventPublisher.HISTORY_REFERENCE_ID, Integer.toString(alert.getSourceHistoryId()));
    ZAP.getEventBus().publishSyncEvent(AlertEventPublisher.getPublisher(), new Event(AlertEventPublisher.getPublisher(), event, new Target(historyReference.getSiteNode()), map));
}
Also used : HistoryReference(org.parosproxy.paros.model.HistoryReference) Target(org.zaproxy.zap.model.Target) HashMap(java.util.HashMap) Event(org.zaproxy.zap.eventBus.Event)

Aggregations

HistoryReference (org.parosproxy.paros.model.HistoryReference)2 Event (org.zaproxy.zap.eventBus.Event)2 HashMap (java.util.HashMap)1 DatabaseException (org.parosproxy.paros.db.DatabaseException)1 SiteMap (org.parosproxy.paros.model.SiteMap)1 SiteNode (org.parosproxy.paros.model.SiteNode)1 Target (org.zaproxy.zap.model.Target)1