protected Response handleRequest(HttpHeaders headers, String body,
                                   UriInfo uriInfo, Request.Type requestType,
                                   MediaType mediaType, ResourceInstance resource) {

    // original request and initial result
    RequestBody rb = new RequestBody();
    rb.setBody(body);
    Request request = getRequestFactory().createRequest(headers, rb, uriInfo, requestType, resource);
    Result result = new ResultImpl(new ResultStatus(ResultStatus.STATUS.OK));

    try {
      Set<RequestBody> requestBodySet = getBodyParser().parse(body);

      Iterator<RequestBody> iterator = requestBodySet.iterator();
      while (iterator.hasNext() && result.getStatus().getStatus().equals(ResultStatus.STATUS.OK)) {
        RequestBody requestBody = iterator.next();

        request = getRequestFactory().createRequest(
            headers, requestBody, uriInfo, requestType, resource);

        result  = request.process();
        // if it is not OK, then it is logged below
        if(ResultStatus.STATUS.OK.equals(result.getStatus().getStatus())) {
          requestAuditLogger.log(request, result);
        }
      }

      if(requestBodySet.isEmpty() || !ResultStatus.STATUS.OK.equals(result.getStatus().getStatus())) {
        requestAuditLogger.log(request, result);
      }
    } catch (BodyParseException e) {
      result =  new ResultImpl(new ResultStatus(ResultStatus.STATUS.BAD_REQUEST, e.getMessage()));
      LOG.error("Bad request received: " + e.getMessage());
      requestAuditLogger.log(request, result);
    } catch (Throwable t) {
      requestAuditLogger.log(request, new ResultImpl(new ResultStatus(ResultStatus.STATUS.SERVER_ERROR, t.getMessage())));
      throw t;
    }

    ResultSerializer serializer = mediaType == null ? getResultSerializer() : getResultSerializer(mediaType);

    Response.ResponseBuilder builder = Response.status(result.getStatus().getStatusCode()).entity(
        serializer.serialize(result));

    if (mediaType != null) {
      builder.type(mediaType);
    }

    RetryHelper.clearAffectedClusters();
    return builder.build();
  }
Requests are funneled through this method so that common logic can be executed.
Creates a request instance and invokes it's process method.

@param headers      http headers
@param body         http body
@param uriInfo      uri information
@param requestType  http request type
@param mediaType    the requested media type; may be null
@param resource     resource instance that is being acted on

@return the response of the operation in serialized form
ambari-server/src/main/java/org/apache/ambari/server/api/services/BaseService.java