Package org.rhq.core.domain.alert.notification

Examples of org.rhq.core.domain.alert.notification.AlertNotificationLog


            if (alertNotifications != null && alertNotifications.size() > 0) {
                AlertSenderPluginManager alertSenderPluginManager = getAlertPluginManager();

                for (AlertNotification alertNotification : alertNotifications) {
                    try {
                        AlertNotificationLog notificationLog = null;

                        String senderName = alertNotification.getSenderName();
                        if (alertSenderPluginManager == null) {
                            notificationLog = new AlertNotificationLog(alert, senderName, ResultState.FAILURE,
                                "Notification was not sent as alert sender plugins are not yet initialized ");

                        } else if (senderName == null) {
                            notificationLog = new AlertNotificationLog(alert, senderName, ResultState.FAILURE,
                                "Sender '" + senderName + "' is not defined");

                        } else {
                            AlertSender<?> notificationSender = alertSenderPluginManager
                                .getAlertSenderForNotification(alertNotification);
                            if (notificationSender == null) {
                                notificationLog = new AlertNotificationLog(alert, senderName, ResultState.FAILURE,
                                    "Failed to obtain a sender with given name");
                            } else {
                                try {
                                    SenderResult result = notificationSender.send(alert);
                                    if (log.isDebugEnabled()) {
                                        log.debug(result);
                                    }

                                    if (result == null) {
                                        notificationLog = new AlertNotificationLog(alert, senderName,
                                            ResultState.UNKNOWN, "Sender did not return any result");
                                    } else {
                                        notificationLog = new AlertNotificationLog(alert, senderName, result);
                                    }
                                } catch (Throwable t) {
                                    log.error("Notification processing terminated abruptly" + t.getMessage());
                                    notificationLog = new AlertNotificationLog(alert, senderName, ResultState.FAILURE,
                                        "Notification processing terminated abruptly, cause: " + t.getMessage());
                                }
                            }
                        }
View Full Code Here


        // make sure we don't exceed the max message length for the db vendor
        DatabaseType dbType = DatabaseTypeFactory.getDefaultDatabaseType();
        String message = dbType.getString(notificationLog.getMessage(), AlertNotificationLog.MESSAGE_MAX_LENGTH);

        if (null != message && !message.equals(notificationLog.getMessage())) {
            notificationLog = new AlertNotificationLog(notificationLog.getAlert(), notificationLog.getSender(),
                notificationLog.getResultState(), message);
        }

        entityManager.persist(notificationLog);
        alert.addAlertNotificatinLog(notificationLog);
View Full Code Here

    private Alert createNewAlert(AlertDefinition ad, long timestamp) {
        Alert a = new Alert(ad, timestamp);
        em.persist(a);

        AlertNotificationLog anl = new AlertNotificationLog(a, "dummy", ResultState.SUCCESS, "message");
        em.persist(anl);

        AlertCondition ac = ad.getConditions().iterator().next();
        AlertConditionLog acl = new AlertConditionLog(ac, timestamp);
        acl.setAlert(a);
View Full Code Here

TOP

Related Classes of org.rhq.core.domain.alert.notification.AlertNotificationLog

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.