/**
   * Whether the original request received by the synapse is REST
   *
   * @param originalInMsgCtx request message
   * @return <code>true</code> if the request was a REST request
   */
  private static boolean isRequestRest(MessageContext originalInMsgCtx) {

    boolean isRestRequest =
        originalInMsgCtx.getProperty(NhttpConstants.REST_REQUEST_CONTENT_TYPE) != null;

    if (!isRestRequest) {

      String httpMethod =
          (String) originalInMsgCtx.getProperty(Constants.Configuration.HTTP_METHOD);

      isRestRequest =
          Constants.Configuration.HTTP_METHOD_GET.equals(httpMethod)
              || Constants.Configuration.HTTP_METHOD_DELETE.equals(httpMethod)
              || Constants.Configuration.HTTP_METHOD_PUT.equals(httpMethod)
              || RESTConstants.METHOD_OPTIONS.equals(httpMethod)
              || Constants.Configuration.HTTP_METHOD_HEAD.equals(httpMethod);

      if (!isRestRequest) {

        isRestRequest =
            Constants.Configuration.HTTP_METHOD_POST.equals(httpMethod)
                && HTTPTransportUtils.isRESTRequest(
                    String.valueOf(
                        originalInMsgCtx.getProperty(Constants.Configuration.MESSAGE_TYPE)));

        if (!isRestRequest) {
          isRestRequest =
              (String.valueOf(originalInMsgCtx.getProperty(Constants.Configuration.MESSAGE_TYPE))
                      .equals(HTTPConstants.MEDIA_TYPE_TEXT_XML)
                  && originalInMsgCtx.getSoapAction() == null);
        }
      }
    }
    return isRestRequest;
  }
  /**
   * This is is a workaround for axis2 RestUtils behaviour Based on an internal property and the
   * http method, we set the message type
   *
   * @param originalInMsgCtx IN message
   * @param axisOutMsgCtx Out message
   */
  private static void processWSDL2RESTRequestMessageType(
      MessageContext originalInMsgCtx, MessageContext axisOutMsgCtx) {

    // TODO - this is a workaround for axis2 RestUtils behaviour
    Object restContentType = originalInMsgCtx.getProperty(NhttpConstants.REST_REQUEST_CONTENT_TYPE);

    if (restContentType == null) {

      String httpMethod =
          (String) originalInMsgCtx.getProperty(Constants.Configuration.HTTP_METHOD);
      if (Constants.Configuration.HTTP_METHOD_GET.equals(httpMethod)
          || Constants.Configuration.HTTP_METHOD_DELETE.equals(httpMethod)) {
        restContentType = HTTPConstants.MEDIA_TYPE_X_WWW_FORM;
      }
    }
    // Removed ESB 4.7.0 PPT 2013-06-28
    //        if (restContentType != null && restContentType instanceof String) {
    //            String contentType = TransportUtils.getContentType((String) restContentType,
    // originalInMsgCtx);
    //            axisOutMsgCtx.setProperty(
    //                    org.apache.axis2.Constants.Configuration.MESSAGE_TYPE, contentType);
    //            originalInMsgCtx.setProperty(
    //                    org.apache.axis2.Constants.Configuration.MESSAGE_TYPE, contentType);
    //        }
  }