if (LOG.isDebugEnabled()) {
LOG.debug("updateGroupAlertDefinition: " + groupAlertDefinition);
}
// first update the actual alert group alert definition
AlertDefinition updated = null;
try {
updated = alertDefinitionManager.updateAlertDefinition(subject, groupAlertDefinition.getId(),
groupAlertDefinition, resetMatching); // do not allow direct undeletes of an alert definition
} catch (Throwable t) {
throw new AlertDefinitionUpdateException("Failed to update a GroupAlertDefinition: "
+ groupAlertDefinition.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 this group alert definition
List<Integer> alertDefinitions = getChildrenAlertDefinitionIds(groupAlertDefinition.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(subject, alertDefinitionId, updated,
resetMatching);
} catch (Throwable t) {
// continue on error, update as many as possible
if (firstThrowable == null) {
firstThrowable = t;
}
alertDefinitionIdsInError.add(alertDefinitionId);
}
}
// if the subject deleted the alertDefinition spawned from a groupAlertDefinition, cascade update will recreate it
List<Integer> resourceIds = getCommittedResourceIdsNeedingGroupAlertDefinitionApplication(overlord,
groupAlertDefinition.getId(), getResourceGroupIdForAlertDefinitionId(groupAlertDefinition.getId()));
List<Integer> resourceIdsInError = new ArrayList<Integer>();
for (Integer resourceId : resourceIds) {
try {
// construct the child
AlertDefinition childAlertDefinition = new AlertDefinition(updated);
childAlertDefinition.setGroupAlertDefinition(groupAlertDefinition);
// persist the child
alertDefinitionManager.createAlertDefinitionInNewTransaction(subject, childAlertDefinition, resourceId,
false);
} catch (Throwable t) {