@SuppressWarnings("unchecked")
  private void updateAlertGroups(Set<Map<String, Object>> requestMaps)
      throws AmbariException, AuthorizationException {

    for (Map<String, Object> requestMap : requestMaps) {
      String stringId = (String) requestMap.get(ALERT_GROUP_ID);

      if( StringUtils.isEmpty(stringId)){
        throw new IllegalArgumentException("The ID of the alert group is required when updating an existing group");
      }

      long id = Long.parseLong(stringId);
      AlertGroupEntity entity = s_dao.findGroupById(id);

      if( null == entity ){
        String message = MessageFormat.format("The alert group with ID {0} could not be found", id);
        throw new AmbariException(message);
      }

      AlertResourceProviderUtils.verifyManageAuthorization(entity, getClusterResourceId(entity.getClusterId()));

      String name = (String) requestMap.get(ALERT_GROUP_NAME);

      // empty arrays are deserialized as HashSet while populated arrays
      // are deserialized as ArrayList; use Collection for safety
      Collection<Long> targetIds = (Collection<Long>) requestMap.get(ALERT_GROUP_TARGETS);
      Collection<Long> definitionIds = (Collection<Long>) requestMap.get(ALERT_GROUP_DEFINITIONS);

      // if targets were supplied, replace existing
      if (null != targetIds) {
        Set<AlertTargetEntity> targets = new HashSet<>();

        List<Long> ids = new ArrayList<>(targetIds.size());
        ids.addAll(targetIds);

        if (ids.size() > 0) {
          targets.addAll(s_dao.findTargetsById(ids));
        }

        entity.setAlertTargets(targets);
      }

      // only the targets should be updatable on default groups; everything
      // else is valid only on regular groups
      if (!entity.isDefault()) {
        // set the name if supplied
        if (!StringUtils.isBlank(name)) {
          entity.setGroupName(name);
        }

        // if definitions were supplied, replace existing
        Set<AlertDefinitionEntity> definitions = new HashSet<>();
        if (null != definitionIds && definitionIds.size() > 0) {
          List<Long> ids = new ArrayList<>(definitionIds.size());
          ids.addAll(definitionIds);
          definitions.addAll(s_definitionDao.findByIds(ids));

          entity.setAlertDefinitions(definitions);
        } else {
          // empty array supplied, clear out existing definitions
          entity.setAlertDefinitions(definitions);
        }
      }

      s_dao.merge(entity);
      AlertGroupsUpdateEvent alertGroupsUpdateEvent = new AlertGroupsUpdateEvent(Collections.singletonList(
          new AlertGroupUpdate(entity)),
          UpdateEventType.UPDATE);
      STOMPUpdatePublisher.publish(alertGroupsUpdateEvent);
    }
  }
Updates existing {@link AlertGroupEntity}s with the specified properties.

@param requestMaps
         a set of property maps, one map for each entity.
@throws AmbariException
          if the entity could not be found.
ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertGroupResourceProvider.java