Examples of AlertNotification


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

        assertEquals("Failed to find the previously created resource level alert definition.", 1, foundDefs.size());

        AlertDefinition foundDef = foundDefs.get(0);

        AlertNotification newNotif = createAlertNotificationForTest(foundDef, false);

        adm.updateAlertDefinition(subject, resourceLevelAlertDefinitionId, foundDef, false);

        assertEquals("Validation should have been called for a new notification during alert def update", 1,
            TestAlertSender.getValidateMethodCallCount());
View Full Code Here

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

        assertEquals("Failed to find the previously created group level alert definition.", 1, foundDefs.size());

        AlertDefinition foundDef = foundDefs.get(0);

        AlertNotification newNotif = createAlertNotificationForTest(foundDef, false);

        GroupAlertDefinitionManagerLocal gadm = LookupUtil.getGroupAlertDefinitionManager();
        gadm.updateGroupAlertDefinitions(subject, foundDef, true);

        //notice that the validation should be called just once, even though in effect we're creating 11 notifs
View Full Code Here

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

        assertEquals("Failed to find the previously created template level alert definition.", 1, foundDefs.size());

        AlertDefinition foundDef = foundDefs.get(0);

        AlertNotification newNotif = createAlertNotificationForTest(foundDef, false);

        AlertTemplateManagerLocal atm = LookupUtil.getAlertTemplateManager();
        atm.updateAlertTemplate(subject, foundDef, true);

        //notice that the validation should be called just once, even though in effect we're creating 11 notifs
View Full Code Here

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

        return def;
    }

    private AlertNotification createAlertNotificationForTest(AlertDefinition alertDefinition, boolean precanned) {
        AlertNotification notif = new AlertNotification(TestAlertSender.NAME);

        Configuration alertConfig = new Configuration();

        //generate random property so that the notifications are distinguishable from each other
        //and are saved separately
        Random randomGenerator = new Random();
        String randomValue = randomGenerator.nextInt(100) + " - " + randomGenerator.nextInt(200);
        alertConfig.put(new PropertySimple(randomValue, randomValue));

        if (precanned) {
            alertConfig.put(new PropertySimple(TestAlertSender.PERSISTENT_PROPERTY_NAME,
                TestAlertSender.PERSISTEN_PROPERTY_EXPECTED_VALUE));
        } else {
            alertConfig.put(new PropertySimple(TestAlertSender.PERSISTENT_PROPERTY_NAME, "persistent"));
            alertConfig.put(new PropertySimple(TestAlertSender.EPHEMERAL_PROPERTY_NAME, "ephemeral"));
        }

        Configuration extraConfig = new Configuration();

        if (precanned) {
            extraConfig.put(new PropertySimple(TestAlertSender.PERSISTENT_PROPERTY_NAME,
                TestAlertSender.PERSISTEN_PROPERTY_EXPECTED_VALUE));
        } else {
            extraConfig.put(new PropertySimple(TestAlertSender.PERSISTENT_PROPERTY_NAME, "persistent"));
            extraConfig.put(new PropertySimple(TestAlertSender.EPHEMERAL_PROPERTY_NAME, "ephemeral"));
        }

        notif.setConfiguration(alertConfig);
        notif.setExtraConfiguration(extraConfig);

        alertDefinition.addAlertNotification(notif);
        notif.setAlertDefinition(alertDefinition);

        return notif;
    }
View Full Code Here

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

        // check if the sender by name exists
        AlertSenderPluginManager pluginManager = alertManager.getAlertPluginManager();

        for (AlertNotificationRest anr : adr.getNotifications()) {

            AlertNotification notification = notificationRestToNotification(alertDefinition, anr);

            notifications.add(notification);
        }

        alertDefinition.setAlertNotifications(notifications);
View Full Code Here

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

        alertDefinition.setAlertDampening(dampening);
    }

    private AlertNotification notificationRestToNotification(AlertDefinition alertDefinition,
                                                             AlertNotificationRest anr) {
        AlertNotification notification = new AlertNotification(anr.getSenderName());
        if (notificationMgr.getAlertInfoForSender(anr.getSenderName()) == null) {
            throw new StuffNotFoundException("AlertSender with name [" + anr.getSenderName() + "]");
        }
        notification.setAlertDefinition(alertDefinition);
        notification.setConfiguration(ConfigurationHelper.mapToConfiguration(anr.getConfig()));
        notification.setExtraConfiguration(ConfigurationHelper.mapToConfiguration(anr.getExtraConfig()));
        return notification;
    }
View Full Code Here

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

    @ApiOperation("Return a notification definition by its id")
    @ApiError(code = 404, reason = "No notification with the passed id found")
    public Response getNotification(
        @ApiParam("The id of the notification definition to retrieve") @PathParam("nid") int notificationId) {

        AlertNotification notification = notificationMgr.getAlertNotification(caller,notificationId);
        if (notification==null) {
            throw new StuffNotFoundException("No notification with id " + notificationId);
        }
        AlertNotificationRest anr = notificationToNotificationRest(notification);
View Full Code Here

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

    })
    public Response deleteNotification(
        @ApiParam("The id of the notification definition to remove") @PathParam("nid") int notificationId,
        @ApiParam("Validate if the notification exists") @QueryParam("validate") @DefaultValue("false") boolean validate) {

        AlertNotification notification = notificationMgr.getAlertNotification(caller,notificationId);
        if (notification!=null) {
            AlertDefinition definition = alertDefinitionManager.getAlertDefinition(caller,notification.getAlertDefinition().getId());

            definition.getAlertNotifications().remove(notification);

            alertDefinitionManager.updateAlertDefinitionInternal(caller,definition.getId(),definition,true,true,true);
View Full Code Here

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

    @ApiError(code = 404, reason = "There is no notification with the passed id")
    public Response updateNotification(
        @ApiParam("The id of the notification definition to update") @PathParam("nid") int notificationId,
        @ApiParam("The updated notification definition to use") AlertNotificationRest notificationRest) {

        AlertNotification notification = notificationMgr.getAlertNotification(caller,notificationId);
        if (notification==null) {
            throw new StuffNotFoundException("No notification with id " + notificationId);
        }

        AlertDefinition definition = alertDefinitionManager.getAlertDefinition(caller,notification.getAlertDefinition().getId());

        AlertNotification newNotif = notificationRestToNotification(definition,notificationRest);
        notification.setConfiguration(newNotif.getConfiguration());
        notification.setExtraConfiguration(newNotif.getExtraConfiguration());
        // id and sender need to stay the same

        alertDefinitionManager.updateAlertDefinitionInternal(caller,definition.getId(),definition,true,true,true);
        entityManager.flush();

        List<AlertNotification> notifications = definition.getAlertNotifications();
        int newNotifId = 0;
        for (AlertNotification n : notifications) {
            if (n.getSenderName().equals(notification.getSenderName())) {
                newNotifId = n.getId();
            }
        }

        AlertNotification result = notificationMgr.getAlertNotification(caller,newNotifId);
        AlertNotificationRest resultRest = notificationToNotificationRest(result);

        return Response.ok(resultRest).build(); // TODO
    }
View Full Code Here

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

        AlertDefinition definition = alertDefinitionManager.getAlertDefinition(caller,definitionId);
        if (definition==null) {
            throw new StuffNotFoundException("AlertDefinition with id " + definitionId);
        }

        AlertNotification notification = notificationRestToNotification(definition, notificationRest);

        // definition and sender are valid, continue
        int existingNotificationCount = definition.getAlertNotifications().size();

//        notification.setAlertDefinition(definition); setting this will result in duplicated notifications
        definition.addAlertNotification(notification);

        alertDefinitionManager.updateAlertDefinitionInternal(caller, definitionId, definition, false, true, true);


        alertDefinitionManager.getAlertDefinition(caller,definitionId);

        entityManager.flush();

        AlertDefinition updatedDefinition = alertDefinitionManager.getAlertDefinitionById(caller,definitionId);

        List<AlertNotification> notifs = updatedDefinition.getAlertNotifications();

        assert notifs.size() == existingNotificationCount +1;

        AlertNotification updatedNotification = notifs.get(existingNotificationCount);
        AlertNotificationRest updatedNotificationRest = notificationToNotificationRest(updatedNotification);

        int notificationId = updatedNotification.getId();

        UriBuilder uriBuilder = uriInfo.getBaseUriBuilder();
        uriBuilder.path("/alert/notification/{nid}");
        URI uri = uriBuilder.build(notificationId );
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.