private String getOperation(Request request) {
    if (request.getRequestType() == Request.Type.DELETE) {
      return "Delete component " + request.getResource().getKeyValueMap().get(Resource.Type.HostComponent);
    }

    if (request.getBody().getRequestInfoProperties() != null && request.getBody().getRequestInfoProperties().containsKey(RequestOperationLevel.OPERATION_LEVEL_ID)) {
      String operation = "";
      switch (request.getBody().getRequestInfoProperties().get(RequestOperationLevel.OPERATION_LEVEL_ID)) {
        case "CLUSTER":
          for (Map<String, Object> map : request.getBody().getPropertySets()) {
            if (map.containsKey(HostComponentResourceProvider.CLUSTER_NAME)) {
              operation = String.valueOf(map.get(HostComponentResourceProvider.STATE)) + ": all services"
                + " on all hosts"
                + (request.getBody().getQueryString() != null && request.getBody().getQueryString().length() > 0 ? " that matches " + request.getBody().getQueryString() : "")
                + " (" + request.getBody().getRequestInfoProperties().get(RequestOperationLevel.OPERATION_CLUSTER_ID) + ")";
              break;
            }
          }
          break;
        case "HOST":
          for (Map<String, Object> map : request.getBody().getPropertySets()) {
            if (map.containsKey(HostComponentResourceProvider.CLUSTER_NAME)) {
              String query = request.getBody().getRequestInfoProperties().get("query");
              operation = String.valueOf(map.get(HostComponentResourceProvider.STATE)) + ": " + query.substring(query.indexOf("(") + 1, query.length() - 1)
                + " on " + request.getBody().getRequestInfoProperties().get(RequestOperationLevel.OPERATION_HOST_NAME)
                + " (" + request.getBody().getRequestInfoProperties().get(RequestOperationLevel.OPERATION_CLUSTER_ID) + ")";
              break;
            }
          }
          break;
        case "HOST_COMPONENT":
          for (Map<String, Object> map : request.getBody().getPropertySets()) {
            if (map.containsKey(HostComponentResourceProvider.COMPONENT_NAME)) {
              operation = String.valueOf(map.get(HostComponentResourceProvider.STATE)) + ": " + String.valueOf(map.get(HostComponentResourceProvider.COMPONENT_NAME))
                + "/" + request.getBody().getRequestInfoProperties().get(RequestOperationLevel.OPERATION_SERVICE_ID)
                + " on " + request.getBody().getRequestInfoProperties().get(RequestOperationLevel.OPERATION_HOST_NAME)
                + " (" + request.getBody().getRequestInfoProperties().get(RequestOperationLevel.OPERATION_CLUSTER_ID) + ")";
              break;
            }
          }
          break;
      }
      return operation;
    }

    for (Map<String, Object> map : request.getBody().getPropertySets()) {
      if (map.containsKey(HostComponentResourceProvider.MAINTENANCE_STATE)) {
        return "Turn " + map.get(HostComponentResourceProvider.MAINTENANCE_STATE) + " Maintenance Mode for " + map.get(HostComponentResourceProvider.COMPONENT_NAME);
      }
    }

    return null;
  }
Generates operation name based on the request. It checks the operation level, the host name, the service name, the status
and whether this is a maintenance mode switch change.
@param request
@return
ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/ComponentEventCreator.java