コード例 #1
0
ファイル: RestClient.java プロジェクト: saeta/rest.li
 /**
  * Sends an untyped REST request using a callback.
  *
  * @param requestContext context for the request
  * @param uri for resource
  * @param method to perform
  * @param dataMap request body entity
  * @param protocolVersion the version of the Rest.li protocol used to build this request
  * @param requestOptions contains compression force on/off overrides, request content type and
  *     accept types
  * @param callback to call on request completion. In the event of an error, the callback will
  *     receive a {@link com.linkedin.r2.RemoteInvocationException}. If a valid error response was
  *     received from the remote server, the callback will receive a {@link
  *     com.linkedin.r2.message.rest.RestException} containing the error details.
  */
 private void sendRequestImpl(
     RequestContext requestContext,
     URI uri,
     ResourceMethod method,
     DataMap dataMap,
     Map<String, String> headers,
     List<String> cookies,
     String methodName,
     ProtocolVersion protocolVersion,
     RestliRequestOptions requestOptions,
     Callback<RestResponse> callback) {
   try {
     RestRequest request =
         buildRequest(
             uri,
             method,
             dataMap,
             headers,
             cookies,
             protocolVersion,
             requestOptions.getContentType(),
             requestOptions.getAcceptTypes());
     String operation = OperationNameGenerator.generate(method, methodName);
     requestContext.putLocalAttr(R2Constants.OPERATION, operation);
     requestContext.putLocalAttr(
         R2Constants.REQUEST_COMPRESSION_OVERRIDE, requestOptions.getRequestCompressionOverride());
     requestContext.putLocalAttr(
         R2Constants.RESPONSE_COMPRESSION_OVERRIDE,
         requestOptions.getResponseCompressionOverride());
     _client.restRequest(request, requestContext, callback);
   } catch (Exception e) {
     // No need to wrap the exception; RestLiCallbackAdapter.onError() will take care of that
     callback.onError(e);
   }
 }
コード例 #2
0
ファイル: Request.java プロジェクト: jxqlovejava/rest.li
  /**
   * Checks if the new fields are equal
   *
   * @param other
   * @return
   */
  private boolean areNewFieldsEqual(Request<?> other) {
    if (!areOldFieldsEqual(other)) {
      return false;
    }
    if (_baseUriTemplate != null
        ? !_baseUriTemplate.equals(other._baseUriTemplate)
        : other._baseUriTemplate != null) {
      return false;
    }
    if (_pathKeys != null ? !_pathKeys.equals(other._pathKeys) : other._pathKeys != null) {
      return false;
    }
    if (_resourceSpec != null
        ? !_resourceSpec.equals(other._resourceSpec)
        : other._resourceSpec != null) {
      return false;
    }
    if (_queryParams != null
        ? !_queryParams.equals(other._queryParams)
        : other._queryParams != null) {
      return false;
    }
    if (_methodName != null ? !_methodName.equals(other._methodName) : other._methodName != null) {
      return false;
    }
    if (_requestOptions != null
        ? !_requestOptions.equals(other._requestOptions)
        : other._requestOptions != null) {
      return false;
    }

    return true;
  }
コード例 #3
0
ファイル: Request.java プロジェクト: jxqlovejava/rest.li
 /**
  * Computes the hashCode using the new fields
  *
  * @return
  */
 @Override
 public int hashCode() {
   int hashCode = _method.hashCode();
   hashCode = 31 * hashCode + (_inputRecord != null ? _inputRecord.hashCode() : 0);
   hashCode = 31 * hashCode + (_headers != null ? _headers.hashCode() : 0);
   hashCode = 31 * hashCode + (_baseUriTemplate != null ? _baseUriTemplate.hashCode() : 0);
   hashCode = 31 * hashCode + (_pathKeys != null ? _pathKeys.hashCode() : 0);
   hashCode = 31 * hashCode + (_resourceSpec != null ? _resourceSpec.hashCode() : 0);
   hashCode = 31 * hashCode + (_queryParams != null ? _queryParams.hashCode() : 0);
   hashCode = 31 * hashCode + (_methodName != null ? _methodName.hashCode() : 0);
   hashCode = 31 * hashCode + (_requestOptions != null ? _requestOptions.hashCode() : 0);
   return hashCode;
 }