Exemplo n.º 1
0
    @Override
    public void onResolved(final Promise<T> promise) {
      if (_executionReportBuilder != null) {
        _executionReportBuilder.setParseqTrace(_associatedTask.getTrace());
      }

      RequestExecutionReport executionReport = getRequestExecutionReport(_executionReportBuilder);

      if (promise.isFailed()) {
        _callback.onError(
            promise.getError() instanceof RestLiServiceException
                ? promise.getError()
                : new RestLiServiceException(
                    HttpStatus.S_500_INTERNAL_SERVER_ERROR, promise.getError()),
            executionReport);
      } else {
        _callback.onSuccess(promise.get(), executionReport);
      }
    }
Exemplo n.º 2
0
 @Override
 public void onSuccess(RestLiRequestData requestData) {
   try {
     ResourceMethodDescriptor resourceMethodDescriptor = _invocableMethod.getResourceMethod();
     Object resource =
         _resourceFactory.create(resourceMethodDescriptor.getResourceModel().getResourceClass());
     if (BaseResource.class.isAssignableFrom(resource.getClass())) {
       ((BaseResource) resource).setContext(_invocableMethod.getContext());
     }
     Object[] args = _restLiArgumentBuilder.buildArguments(requestData, _invocableMethod);
     // Now invoke the resource implementation.
     doInvoke(
         resourceMethodDescriptor, _callback, _requestExecutionReportBuilder, resource, args);
   } catch (Exception e) {
     _callback.onError(
         e,
         _requestExecutionReportBuilder == null ? null : _requestExecutionReportBuilder.build());
   }
 }
Exemplo n.º 3
0
 @Override
 public void onError(Throwable throwable) {
   _callback.onError(
       throwable,
       _requestExecutionReportBuilder == null ? null : _requestExecutionReportBuilder.build());
 }
Exemplo n.º 4
0
 private static RequestExecutionReport getRequestExecutionReport(
     RequestExecutionReportBuilder requestExecutionReportBuilder) {
   return requestExecutionReportBuilder == null ? null : requestExecutionReportBuilder.build();
 }