Examples of AlertDefinition


Examples of org.rhq.core.domain.alert.AlertDefinition

        query.setParameter("resourceId", resourceId);
        List<AlertDefinition> unappliedTemplates = query.getResultList();

        for (AlertDefinition template : unappliedTemplates) {
            // construct the child, note that the proxy will pull in lazy data during the copy
            AlertDefinition childAlertDefinition = new AlertDefinition(template);
            childAlertDefinition.setParentId(template.getId());

            // persist the child, user is known to be overlord at this point for this system side-effect
            try {
                // convert the childAlertDef to a pojo, remove all proxies left over from the copy. We can't
                // pass entities across a Tx boundary and the call to create the alert def is executed in a new trans.
View Full Code Here

Examples of org.rhq.core.domain.alert.AlertDefinition

        if (null == alertTemplateIds || alertTemplateIds.length == 0) {
            return;
        }

        for (Integer alertTemplateId : alertTemplateIds) {
            AlertDefinition template = entityManager.find(AlertDefinition.class, alertTemplateId);
            if (null == template || template.getDeleted()) {
                continue;
            }

            // remove the template
            template.setDeleted(true);

            // remove the child resource-level defs
            Subject overlord = subjectManager.getOverlord();
            List<Integer> childDefinitionIds = getChildrenAlertDefinitionIds(user, alertTemplateId);
            if (childDefinitionIds.isEmpty()) {
View Full Code Here

Examples of org.rhq.core.domain.alert.AlertDefinition

        if (null == alertTemplateIds || alertTemplateIds.length == 0) {
            return;
        }

        for (Integer alertTemplateId : alertTemplateIds) {
            AlertDefinition template = entityManager.find(AlertDefinition.class, alertTemplateId);
            if (null == template || template.getEnabled() || template.getDeleted()) {
                continue;
            }

            // enable the template
            template.setEnabled(true);

            // enable the child resource-level defs
            Subject overlord = subjectManager.getOverlord();
            List<Integer> childDefinitionIds = getChildrenAlertDefinitionIds(overlord, alertTemplateId);
            if (childDefinitionIds.isEmpty()) {
View Full Code Here

Examples of org.rhq.core.domain.alert.AlertDefinition

        if (null == alertTemplateIds || alertTemplateIds.length == 0) {
            return;
        }

        for (Integer alertTemplateId : alertTemplateIds) {
            AlertDefinition template = entityManager.find(AlertDefinition.class, alertTemplateId);
            if (null == template || !template.getEnabled() || template.getDeleted()) {
                continue;
            }

            // disable the template
            template.setEnabled(false);

            // enable the child resource-level defs
            Subject overlord = subjectManager.getOverlord();
            List<Integer> childDefinitionIds = getChildrenAlertDefinitionIds(overlord, alertTemplateId);
            if (childDefinitionIds.isEmpty()) {
View Full Code Here

Examples of org.rhq.core.domain.alert.AlertDefinition

        if (LOG.isDebugEnabled()) {
            LOG.debug("updateAlertTemplate: " + alertTemplate);
        }

        // first update the actual alert template
        AlertDefinition updated = null;
        try {
            updated = alertDefinitionManager.updateAlertDefinition(user, alertTemplate.getId(), alertTemplate,
                resetMatching); // do not allow direct undeletes of an alert definition
        } catch (Throwable t) {
            throw new AlertDefinitionUpdateException("Failed to update an AlertTemplate "
                + alertTemplate.toSimpleString(), t);
        }

        // overlord will be used for all system-side effects as a result of updating this alert template
        Subject overlord = subjectManager.getOverlord();
        Throwable firstThrowable = null;

        // update all of the definitions that were spawned from alert templates
        List<Integer> alertDefinitions = getChildrenAlertDefinitionIds(overlord, alertTemplate.getId());
        if (LOG.isDebugEnabled()) {
            LOG.debug("Need to update the following children alert definition ids: " + alertDefinitions);
        }
        List<Integer> alertDefinitionIdsInError = new ArrayList<Integer>();
        for (Integer alertDefinitionId : alertDefinitions) {
            try {
                alertDefinitionManager.updateDependentAlertDefinition(user, alertDefinitionId, updated, resetMatching);
            } catch (Throwable t) {
                // continue on error, update as many as possible
                if (firstThrowable == null) {
                    firstThrowable = t;
                }
                alertDefinitionIdsInError.add(alertDefinitionId);
            }
        }

        // if the user deleted the alert definition spawned from a template, a cascade update will recreate it
        List<Integer> resourceIds = getCommittedResourceIdsNeedingTemplateApplication(overlord, alertTemplate.getId(),
            getResourceTypeIdForAlertTemplateId(alertTemplate.getId()));
        if (LOG.isDebugEnabled()) {
            LOG.debug("Need to re-create alert definitions for the following resource ids: " + resourceIds);
        }
        List<Integer> resourceIdsInError = new ArrayList<Integer>();
        for (Integer resourceId : resourceIds) {
            try {
                // construct the child
                AlertDefinition childAlertDefinition = new AlertDefinition(updated);
                childAlertDefinition.setParentId(alertTemplate.getId());

                // persist the child
                alertDefinitionManager.createAlertDefinitionInNewTransaction(overlord, childAlertDefinition,
                    resourceId, false);
            } catch (Throwable t) {
View Full Code Here

Examples of org.rhq.core.domain.alert.AlertDefinition

        if (log.isDebugEnabled()) {
            log.debug("Firing an alert for alertDefinition with id=" + alertDefinitionId + "...");
        }

        Subject overlord = subjectManager.getOverlord();
        AlertDefinition alertDefinition = alertDefinitionManager.getAlertDefinitionById(overlord, alertDefinitionId);

        /*
         * creating an alert via an alertDefinition automatically creates the needed auditing data structures such as
         * alertConditionLogs and alertNotificationLogs
         */
 
View Full Code Here

Examples of org.rhq.core.domain.alert.AlertDefinition

        if (emailAddresses.size() == 0) {
            return new ArrayList<String>(0); // No email to send -> no bad addresses
        }

        AlertDefinition alertDefinition = alert.getAlertDefinition();
        Resource resource = alertDefinition.getResource();
        Map<Integer, String> ancestry = resourceManager.getResourcesAncestry(subjectManager.getOverlord(),
            new Integer[] { resource.getId() }, ResourceAncestryFormat.VERBOSE);
        Map<String, String> alertMessage = emailManager.getAlertEmailMessage(ancestry.get(resource.getId()), //
            resource.getName(), //
            alertDefinition.getName(), //
            alertDefinition.getPriority().toString(), //
            new Date(alert.getCtime()).toString(), //
            prettyPrintAlertConditions(alert.getConditionLogs(), false), //
            prettyPrintAlertURL(alert));

        String messageSubject = alertMessage.keySet().iterator().next();
View Full Code Here

Examples of org.rhq.core.domain.alert.AlertDefinition

        if (recoveryDefinitionId != 0) {
            if (log.isDebugEnabled()) {
                log.debug("Processing recovery rules... Found recoveryDefinitionId " + recoveryDefinitionId);
            }

            AlertDefinition toBeRecoveredDefinition = alertDefinitionManager.getAlertDefinitionById(overlord,
                recoveryDefinitionId);
            boolean wasEnabled = toBeRecoveredDefinition.getEnabled();

            if (log.isDebugEnabled()) {
                log.debug(firedDefinition + (wasEnabled ? "does not need to recover " : "needs to recover ")
                    + toBeRecoveredDefinition
                    + (wasEnabled ? ", it was already enabled " : ", it was currently disabled "));
View Full Code Here

Examples of org.rhq.core.domain.alert.AlertDefinition

     * @return true if the definition got disabled
     */
    @Override
    public boolean willDefinitionBeDisabled(Alert alert) {
        entityManager.refresh(alert);
        AlertDefinition firedDefinition = alert.getAlertDefinition();
        Subject overlord = subjectManager.getOverlord();
        Integer recoveryDefinitionId = firedDefinition.getRecoveryId();

        if (recoveryDefinitionId != 0) {
            AlertDefinition toBeRecoveredDefinition = alertDefinitionManager.getAlertDefinitionById(overlord,
                recoveryDefinitionId);
            boolean wasEnabled = toBeRecoveredDefinition.getEnabled();
            if (!wasEnabled)
                return false;
        } else if (firedDefinition.getWillRecover()) {
            return true;
        }
View Full Code Here

Examples of org.rhq.core.domain.alert.AlertDefinition

    }

    @Deprecated
    @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
    public int removeNotifications(Subject subject, Integer alertDefinitionId, Integer[] notificationIds) {
        AlertDefinition alertDefinition = getDetachedAlertDefinition(alertDefinitionId); // permissions check first
        if ((notificationIds == null) || (notificationIds.length == 0)) {
            return 0;
        }

        Set<Integer> notificationIdSet = new HashSet<Integer>(Arrays.asList(notificationIds));
        List<AlertNotification> notifications = alertDefinition.getAlertNotifications();
        List<AlertNotification> toBeRemoved = new ArrayList<AlertNotification>();

        int removed = 0;
        for (AlertNotification notification : notifications) {
            if (notificationIdSet.contains(notification.getId())) {
                toBeRemoved.add(notification);
                removed--;
            }
        }

        alertDefinition.getAlertNotifications().removeAll(toBeRemoved);

        postProcessAlertDefinition(subject, alertDefinition);

        return removed;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.