public void deleteAlertsForPolicy(PolicyItem pi) { List ids = new ArrayList(); synchronized (alerts) { Iterator it = alerts.iterator(); while (it.hasNext()) { AlertItem alert = (AlertItem) it.next(); if (alert.getPolicyItem() == pi) { ids.add(alert); } } } Iterator it = ids.iterator(); while (it.hasNext()) { AlertItem alert = (AlertItem) it.next(); model.removeAlert(alert); deleteFromSource(alert); } }
private void deleteAlertTypeForHost() { List ids = new ArrayList(); long[] lids = null; synchronized (alerts) { int row = table.getSelectedRow(); AlertItem item = (AlertItem) model.getAlert(row); if (item != null) { long ip = item.getFlowId().getSourceIP(); long pId = item.getPolicyID(); Iterator it = alerts.iterator(); while (it.hasNext()) { AlertItem alert = (AlertItem) it.next(); if (alert.getPolicyID() == pId && alert.getFlowId().getSourceIP() == ip) { ids.add(alert); } } } } if (JOptionPane.showConfirmDialog(this, "Delete " + ids.size() + " Alerts?") != JOptionPane.YES_OPTION) { return; } lids = new long[ids.size()]; for (int i = 0; i < lids.length; i++) { AlertItem alert = (AlertItem) ids.get(i); lids[i] = alert.getAlertID(); model.removeAlert(alert); deleteFromSource(alert); } try { main.deleteAlertList(lids); } catch (IOException ex) { ex.printStackTrace(); } }
private void deleteAlerts(int[] rows) { long[] alertsIds = new long[rows.length]; AlertItem[] alerts = new AlertItem[rows.length]; for (int i = 0; i < rows.length; i++) { AlertItem item = model.getAlert(rows[i]); alerts[i] = item; alertsIds[i] = item.getAlertID(); } for (int i = 0; i < alerts.length; i++) { model.removeAlert(alerts[i]); deleteFromSource(alerts[i]); } if (alertsIds != null) { try { main.deleteAlertList(alertsIds); } catch (IOException ex) { } } }