Skip to content
This repository has been archived by the owner on Jul 11, 2022. It is now read-only.

Commit

Permalink
Bug 1532387 - Create child alerts for groups and templates
Browse files Browse the repository at this point in the history
  • Loading branch information
josejulio authored and spinder committed Jan 25, 2018
1 parent 5ebe8e4 commit 8460f6c
Showing 1 changed file with 21 additions and 2 deletions.
Expand Up @@ -87,6 +87,8 @@
import org.rhq.enterprise.server.alert.AlertDefinitionManagerLocal;
import org.rhq.enterprise.server.alert.AlertManagerLocal;
import org.rhq.enterprise.server.alert.AlertNotificationManagerLocal;
import org.rhq.enterprise.server.alert.AlertTemplateManagerLocal;
import org.rhq.enterprise.server.alert.GroupAlertDefinitionManagerLocal;
import org.rhq.enterprise.server.operation.OperationManagerLocal;
import org.rhq.enterprise.server.plugin.pc.alert.AlertSenderInfo;
import org.rhq.enterprise.server.plugin.pc.alert.AlertSenderPluginManager;
Expand Down Expand Up @@ -131,6 +133,12 @@ public class AlertDefinitionHandlerBean extends AbstractRestBean {
@EJB
private OperationManagerLocal operationMgr;

@EJB
private GroupAlertDefinitionManagerLocal groupAlertDefinitionManager;

@EJB
private AlertTemplateManagerLocal alertTemplateManager;


@PersistenceContext(unitName = RHQConstants.PERSISTENCE_UNIT_NAME)
private EntityManager entityManager;
Expand Down Expand Up @@ -310,8 +318,19 @@ public Response createAlertDefinition(@ApiParam("The id of the resource to attac
throw new StuffNotFoundException("Recovery alert with id " + adr.getRecoveryId());
}

AlertDefinition updatedDefinition = alertDefinitionManager.createAlertDefinitionInNewTransaction(caller,
alertDefinition, resourceId, false);
AlertDefinition updatedDefinition;
if (groupId != null) {
int alertDefinitionId = groupAlertDefinitionManager.createGroupAlertDefinitions(
caller, alertDefinition, groupId);
updatedDefinition = alertDefinitionManager.getAlertDefinition(caller, alertDefinitionId);
} else if (resourceTypeId != null) {
int alertDefinitionId = alertTemplateManager.createAlertTemplate(caller, alertDefinition, resourceTypeId);
updatedDefinition = alertDefinitionManager.getAlertDefinition(caller, alertDefinitionId);
} else {
updatedDefinition = alertDefinitionManager.createAlertDefinitionInNewTransaction(caller,
alertDefinition, resourceId, false);
}

int definitionId = updatedDefinition.getId();
AlertDefinitionRest uadr = definitionToDomain(updatedDefinition,true, uriInfo) ; // TODO param 'full' ?

Expand Down

0 comments on commit 8460f6c

Please sign in to comment.