@Transactional
  @SuppressWarnings("unchecked")
  void updateAlertTargets(long alertTargetId,
      Map<String, Object> requestMap)
      throws AmbariException {

    AlertTargetEntity entity = s_dao.findTargetById(alertTargetId);

    if (null == entity) {
      String message = MessageFormat.format(
          "The alert target with ID {0} could not be found", alertTargetId);

      throw new AmbariException(message);
    }

    String name = (String) requestMap.get(ALERT_TARGET_NAME);
    String description = (String) requestMap.get(ALERT_TARGET_DESCRIPTION);
    String notificationType = (String) requestMap.get(ALERT_TARGET_NOTIFICATION_TYPE);
    Collection<String> alertStates = (Collection<String>) requestMap.get(ALERT_TARGET_STATES);
    Collection<Long> groupIds = (Collection<Long>) requestMap.get(ALERT_TARGET_GROUPS);
    String isGlobal = (String) requestMap.get(ALERT_TARGET_GLOBAL);
    String isEnabled = (String) requestMap.get(ALERT_TARGET_ENABLED);

    if(null != isGlobal){
      entity.setGlobal(Boolean.parseBoolean(isGlobal));
    }

    if (null != isEnabled) {
      entity.setEnabled(Boolean.parseBoolean(isEnabled));
    }

    if (!StringUtils.isBlank(name)) {
      entity.setTargetName(name);
    }

    if (null != description) {
      entity.setDescription(description);
    }

    if (!StringUtils.isBlank(notificationType)) {
      entity.setNotificationType(notificationType);
    }

    Map<String, Object> propertiesMap = extractProperties(requestMap);

    if (propertiesMap != null) {
      String properties = s_gson.toJson(propertiesMap);
      if (!StringUtils.isEmpty(properties)) {
        LOG.debug("Updating Alert Target properties map to: " + properties);
        entity.setProperties(properties);
      }
    }

    // a null alert state implies that the key was not set and no update
    // should occur for this field, while an empty list implies all alert
    // states should be set
    if (null != alertStates) {
      final Set<AlertState> alertStateSet;
      if (alertStates.isEmpty()) {
        alertStateSet = EnumSet.allOf(AlertState.class);
      } else {
        alertStateSet = new HashSet<>(alertStates.size());
        for (String state : alertStates) {
          alertStateSet.add(AlertState.valueOf(state));
        }
      }

      entity.setAlertStates(alertStateSet);
    }

    // if groups were supplied, replace existing
    if (null != groupIds) {
      Set<AlertGroupEntity> groups = new HashSet<>();
      List<Long> ids = new ArrayList<>(groupIds);

      if (ids.size() > 0) {
        groups.addAll(s_dao.findGroupsById(ids));
      }

      entity.setAlertGroups(groups);
    } else if (entity.isGlobal()){
      Set<AlertGroupEntity> groups = new HashSet<>(s_dao.findAllGroups());
      entity.setAlertGroups(groups);
    }

    // merge the entity, cascading the merge to other entities, like groups
    s_dao.merge(entity);
  }
Updates existing {@link AlertTargetEntity}s with the specified properties.

@param requestMap
         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/AlertTargetResourceProvider.java