Examples of AlertDefinition


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

        Query purgeQuery = entityManager.createNamedQuery(AlertNotification.QUERY_DELETE_ORPHANED);
        return purgeQuery.executeUpdate();
    }

    private AlertDefinition postProcessAlertDefinition(Subject subject, AlertDefinition definition) {
        AlertDefinition updated = null;
        AlertDefinitionContext context = definition.getContext();
        if (context == AlertDefinitionContext.Type) {
            updated = alertTemplateManager.updateAlertTemplate(subject, definition, true);
        } else if (context == AlertDefinitionContext.Group) {
            updated = groupAlertDefintionManager.updateGroupAlertDefinitions(subject, definition, true);
View Full Code Here

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

     * @return list of defined notification of the passed alert definition
     *
     *
     */
    public List<AlertNotification> getNotificationsForAlertDefinition(Subject user, int alertDefinitionId) {
        AlertDefinition definition = alertDefinitionManager.getAlertDefinition(user, alertDefinitionId);
        if (definition == null) {
            LOG.error("Did not find definition for id [" + alertDefinitionId + "]");
            return new ArrayList<AlertNotification>();
        }

        List<AlertNotification> notifications = definition.getAlertNotifications();
        for (AlertNotification notification : notifications) {
            notification.getConfiguration().getProperties().size(); // eager load
            if (notification.getExtraConfiguration() != null) {
                notification.getExtraConfiguration().getProperties().size();
            }
View Full Code Here

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

        return new PageList<AlertDefinition>(list, (int) totalCount, pageControl);
    }

    @Override
    public AlertDefinition getAlertDefinitionById(Subject subject, int alertDefinitionId) {
        AlertDefinition alertDefinition = entityManager.find(AlertDefinition.class, alertDefinitionId);
        if (alertDefinition == null) {
            return null; // fail-fast to avoid downstream NPEs
        }

        if (checkViewPermission(subject, alertDefinition) == false) {
            throw new PermissionException("User[" + subject.getName()
                + "] does not have permission to view alertDefinition[id=" + alertDefinitionId + "] for resource[id="
                + alertDefinition.getResource().getId() + "]");
        }

        alertDefinition.getConditions().size();
        // this is now lazy
        for (AlertCondition cond : alertDefinition.getConditions()) {
            if (cond.getMeasurementDefinition() != null) {
                cond.getMeasurementDefinition().getId();
            }
        }
        // DO NOT LOAD ALL ALERTS FOR A DEFINITION... This would be all alerts that have been fired
        //alertDefinition.getAlertsForResource().size();
        for (AlertNotification notification : alertDefinition.getAlertNotifications()) {
            notification.getConfiguration().getProperties().size(); // eager load configuration and properties too
            if (notification.getExtraConfiguration() != null) {
                notification.getExtraConfiguration().getProperties().size();
            }
        }
View Full Code Here

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

    @Override
    @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
    public int createDependentAlertDefinition(Subject subject, AlertDefinition alertDefinition, int resourceId)
        throws InvalidAlertDefinitionException {
        AlertDefinition newAlertDefinition = createAlertDefinitionInternal(subject, alertDefinition, resourceId, false,
            false);
        return newAlertDefinition.getId();
    }
View Full Code Here

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

    @Override
    @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
    public AlertDefinition createAlertDefinitionInNewTransaction(Subject subject, AlertDefinition alertDefinition,
        Integer resourceId, boolean validateNotificationConfiguration) throws InvalidAlertDefinitionException {
        AlertDefinition newAlertDefinition = createAlertDefinitionInternal(subject, alertDefinition, resourceId, true,
            validateNotificationConfiguration);
        return newAlertDefinition;
    }
View Full Code Here

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

        if ((resourceId != null) && alertDefinition.getEnabled()) {
            // if this is a recovery alert
            if (alertDefinition.getRecoveryId() != 0) {
                // only add to the cache if the to-be-recovered definition is disabled, and thus needs recovering
                // use entityManager direct to bypass security checks, we already know this user is authorized
                AlertDefinition toBeRecoveredDefinition = entityManager.find(AlertDefinition.class,
                    alertDefinition.getRecoveryId());
                if (toBeRecoveredDefinition.getEnabled() == false) {
                    addToCache = true;
                }
            } else {
                addToCache = true;
            }
View Full Code Here

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

    public int enableResourceAlertDefinitions(Subject subject, int[] resourceAlertDefinitionIds) {

        int modifiedCount = 0;

        for (int alertDefId : resourceAlertDefinitionIds) {
            AlertDefinition alertDefinition = entityManager.find(AlertDefinition.class, alertDefId);
            if (null == alertDefinition) {
                continue;
            }

            // only enable an alert if it's not currently enabled
            if (!alertDefinition.getEnabled()) {
                alertDefinition.setEnabled(true);
                modifiedCount++;

                notifyAlertConditionCacheManager(subject, "enableResourceAlertDefinitions", alertDefinition,
                    AlertDefinitionEvent.ENABLED);
            }
View Full Code Here

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

    public int disableResourceAlertDefinitions(Subject subject, int[] resourceAlertDefinitionIds) {

        int modifiedCount = 0;

        for (int alertDefId : resourceAlertDefinitionIds) {
            AlertDefinition alertDefinition = entityManager.find(AlertDefinition.class, alertDefId);
            if (null == alertDefinition) {
                continue;
            }

            // only disable an alert if it's not currently disabled
            if (alertDefinition.getEnabled()) {
                alertDefinition.setEnabled(false);
                modifiedCount++;

                notifyAlertConditionCacheManager(subject, "disableResourceAlertDefinitions", alertDefinition,
                    AlertDefinitionEvent.DISABLED);
            }
View Full Code Here

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

    public int removeResourceAlertDefinitions(Subject subject, int[] resourceAlertDefinitionIds) {

        int modifiedCount = 0;

        for (int alertDefId : resourceAlertDefinitionIds) {
            AlertDefinition alertDefinition = entityManager.find(AlertDefinition.class, alertDefId);
            if (null == alertDefinition) {
                continue;
            }

            // only remove an alert if it's not currently deleted
            if (!alertDefinition.getDeleted()) {
                alertDefinition.setDeleted(true);
                modifiedCount++;

                notifyAlertConditionCacheManager(subject, "removeResourceAlertDefinitions", alertDefinition,
                    AlertDefinitionEvent.DELETED);
            }
View Full Code Here

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

    }

    @Override
    public void copyAlertDefinitions(Subject subject, Integer[] alertDefinitionIds) {
        for (int alertDefId : alertDefinitionIds) {
            AlertDefinition alertDefinition = entityManager.find(AlertDefinition.class, alertDefId);

            // TODO GH: Can be more efficient
            if (checkPermission(subject, alertDefinition)) {
                AlertDefinition newAlertDefinition = new AlertDefinition(alertDefinition);
                newAlertDefinition.setEnabled(false);

                // this is a "true" copy, so update parentId, resource, and resourceType, group, groupAlertDefinition
                newAlertDefinition.setParentId(alertDefinition.getParentId());
                newAlertDefinition.setResource(alertDefinition.getResource());
                newAlertDefinition.setResourceType(alertDefinition.getResourceType());
                newAlertDefinition.setGroup(alertDefinition.getGroup());
                newAlertDefinition.setGroupAlertDefinition(alertDefinition.getGroupAlertDefinition());

                entityManager.persist(newAlertDefinition);

                notifyAlertConditionCacheManager(subject, "copyAlertDefinitions", alertDefinition,
                    AlertDefinitionEvent.CREATED);
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.