Package org.rhq.enterprise.server.alert

Examples of org.rhq.enterprise.server.alert.AlertManagerLocal


        // Get alert definition name
        Integer alertId = new Integer(request.getParameter("a"));

        Subject subject = RequestUtils.getSubject(request);

        AlertManagerLocal alertManager = LookupUtil.getAlertManager();
        AlertCriteria criteria = new AlertCriteria();
        criteria.addFilterId(alertId);
        List<Alert> results = alertManager.findAlertsByCriteria(subject, criteria);

        if (results.size() == 0) {
            request.setAttribute(AttrConstants.TITLE_PARAM2_ATTR, "! Alert not found !");
        } else {
            Alert alert = results.get(0);
View Full Code Here


    public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {

        Subject subject = RequestUtils.getSubject(request);
        AlertManagerLocal alertManager = LookupUtil.getAlertManager();

        Map params = new HashMap(3);
        // pass-through the alertId and resource id
        Integer alertId = new Integer(request.getParameter("a"));
        request.setAttribute("a", alertId);
        params.put("a", alertId);

        Integer resourceId = new Integer(request.getParameter("id"));
        request.setAttribute("id", resourceId);
        params.put("id", resourceId);

        String mode = request.getParameter("mode");
        request.setAttribute("mode", mode);
        params.put("mode", mode);

        alertManager.acknowledgeAlerts(subject, new int[] { alertId });

        log.debug("Acknowledged Alert with id " + alertId + " and user " + subject.getName());

        return returnSuccess(request, mapping, params);
    }
View Full Code Here

        alerts = getAlerts(resourceWithSchedules.getId());
        assert alerts.size() == 1 : "1 alert should have fired: " + alerts;
    }

    private PageList<Alert> getAlerts(int resourceId) {
        AlertManagerLocal alertManager = LookupUtil.getAlertManager();
        AlertCriteria alertCriteria = new AlertCriteria();
        alertCriteria.addFilterResourceIds(resourceId);
        alertCriteria.fetchConditionLogs(true);
        return alertManager.findAlertsByCriteria(getOverlord(), alertCriteria);
    }
View Full Code Here

        return ret;
    }

    private String replaceAlertToken(Token token, Alert alert) {

        AlertManagerLocal mgr = LookupUtil.getAlertManager();

        switch (token) {
        case ALERT_ID:
            return String.valueOf(alert.getId());
        case ALERT_FIRE_TIME:
            return new Date(alert.getCtime()).toString(); // TODO use a specific impl here?
        case ALERT_WILL_RECOVER:
            return String.valueOf(alert.getAlertDefinition().getWillRecover());
        case ALERT_WILL_DISABLE:
            return String.valueOf(mgr.willDefinitionBeDisabled(alert));
        case ALERT_DEF_NAME:
            return alert.getAlertDefinition().getName();
        case ALERT_DEF_DESC:
            return alert.getAlertDefinition().getDescription();
        case ALERT_DEF_PRIO:
            return alert.getAlertDefinition().getPriority().getName();
        case ALERT_URL:
            return mgr.prettyPrintAlertURL(alert);
        case ALERT_CONDITIONS:
            return mgr.prettyPrintAlertConditions(alert, false);

        default:
            return NOT_YET_IMPLEMENTED;
        }
View Full Code Here

    @Override
    public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
        RSSFeed feed = getNewRSSFeed(request);

        AlertManagerLocal alertManager = LookupUtil.getAlertManager();

        // Set title
        MessageResources res = getResources(request);
        feed.setTitle(res.getMessage("dash.home.CriticalAlerts"));

        // Get the alerts
        WebUser user = getWebUser(request);
        if (user != null) {

            AlertsPortletPreferences prefs = user.getWebPreferences().getAlertsPortletPreferences();

            PageControl pageControl = new PageControl(0, prefs.count);

            AlertCriteria criteria = new AlertCriteria();
            criteria.addFilterPriorities(AlertPriority.getByLegacyIndex(prefs.priority));
            criteria.addFilterStartTime(prefs.timeRange);
            criteria.addFilterResourceIds(("all".equals(prefs.displayAll) ? null : ArrayUtils.wrapInArray(prefs
                .asArray())));
            criteria.setPageControl(pageControl);

            PageList<Alert> alerts = alertManager.findAlertsByCriteria(user.getSubject(), criteria);

            if ((alerts != null) && (alerts.size() > 0)) {
                for (Alert alert : alerts) {
                    String link = feed.getBaseUrl() + "/alerts/Alerts.do?mode=viewAlert&id="
                        + alert.getAlertDefinition().getResource().getId() + "&a=" + alert.getId();
View Full Code Here

TOP

Related Classes of org.rhq.enterprise.server.alert.AlertManagerLocal

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.