Package com.google.gwt.requestfactory.shared

Examples of com.google.gwt.requestfactory.shared.ServerFailure


      final TransportReceiver receiver) {
    return new RequestCallback() {

      public void onError(Request request, Throwable exception) {
        wireLogger.log(Level.SEVERE, SERVER_ERROR, exception);
        receiver.onTransportFailure(new ServerFailure(exception.getMessage()));
      }

      public void onResponseReceived(Request request, Response response) {
        wireLogger.finest("Response received");
        if (Response.SC_OK == response.getStatusCode()) {
          String text = response.getText();
          receiver.onTransportSuccess(text);
        } else {
          String message = SERVER_ERROR + " " + response.getStatusCode() + " "
              + response.getText();
          wireLogger.severe(message);
          receiver.onTransportFailure(new ServerFailure(message));
        }
      }
    };
  }
View Full Code Here


* Default implementation for handling exceptions thrown while processing a
* request. Suppresses stack traces and the exception class name.
*/
public class DefaultExceptionHandler implements ExceptionHandler {
  public ServerFailure createServerFailure(Throwable throwable) {
    return new ServerFailure("Server Error: "
        + (throwable == null ? null : throwable.getMessage()), null, null, true);
  }
View Full Code Here

    }
  }

  private AutoBean<ServerFailureMessage> createFailureMessage(
      ReportableException e) {
    ServerFailure failure = exceptionHandler.createServerFailure(e.getCause() == null
        ? e : e.getCause());
    AutoBean<ServerFailureMessage> bean = FACTORY.failure();
    ServerFailureMessage msg = bean.as();
    msg.setExceptionType(failure.getExceptionType());
    msg.setMessage(failure.getMessage());
    msg.setStackTrace(failure.getStackTraceString());
    msg.setFatal(failure.isFatal());
    return bean;
  }
View Full Code Here

        System.out.println("<<< " + result);
      }
      receiver.onTransportSuccess(result);
    } catch (RuntimeException e) {
      e.printStackTrace();
      receiver.onTransportFailure(new ServerFailure(e.getMessage()));
    }
  }
View Full Code Here

      public void onTransportSuccess(String payload) {
        ResponseMessage response = AutoBeanCodex.decode(
            MessageFactoryHolder.FACTORY, ResponseMessage.class, payload).as();
        if (response.getGeneralFailure() != null) {
          ServerFailureMessage failure = response.getGeneralFailure();
          ServerFailure fail = new ServerFailure(failure.getMessage(),
              failure.getExceptionType(), failure.getStackTrace(),
              failure.isFatal());

          fail(receiver, fail);
          return;
        }

        // Process violations and then stop
        if (response.getViolations() != null) {
          Set<Violation> errors = new HashSet<Violation>();
          for (ViolationMessage message : response.getViolations()) {
            errors.add(new MyViolation(message));
          }

          reuse();
          for (AbstractRequest<?> request : new ArrayList<AbstractRequest<?>>(
              invocations)) {
            request.onViolation(errors);
          }
          if (receiver != null) {
            receiver.onViolation(errors);
          }
          return;
        }

        // Process operations
        processReturnOperations(response);

        // Send return values
        for (int i = 0, j = invocations.size(); i < j; i++) {
          if (response.getStatusCodes().get(i)) {
            invocations.get(i).onSuccess(response.getInvocationResults().get(i));
          } else {
            ServerFailureMessage failure = AutoBeanCodex.decode(
                MessageFactoryHolder.FACTORY, ServerFailureMessage.class,
                response.getInvocationResults().get(i)).as();
            invocations.get(i).onFail(
                new ServerFailure(failure.getMessage(),
                    failure.getExceptionType(), failure.getStackTrace(),
                    failure.isFatal()));
          }
        }
View Full Code Here

      final TransportReceiver receiver) {
    return new RequestCallback() {

      public void onError(Request request, Throwable exception) {
        wireLogger.log(Level.SEVERE, SERVER_ERROR, exception);
        receiver.onTransportFailure(new ServerFailure(exception.getMessage()));
      }

      public void onResponseReceived(Request request, Response response) {
        wireLogger.finest("Response received");
        if (Response.SC_OK == response.getStatusCode()) {
          String text = response.getText();
          receiver.onTransportSuccess(text);
        } else {
          String message = SERVER_ERROR + " " + response.getStatusCode() + " "
              + response.getText();
          wireLogger.severe(message);
          receiver.onTransportFailure(new ServerFailure(message));
        }
      }
    };
  }
View Full Code Here

    }
  }

  private AutoBean<ServerFailureMessage> createFailureMessage(
      ReportableException e) {
    ServerFailure failure = exceptionHandler.createServerFailure(e.getCause() == null
        ? e : e.getCause());
    AutoBean<ServerFailureMessage> bean = FACTORY.failure();
    ServerFailureMessage msg = bean.as();
    msg.setExceptionType(failure.getExceptionType());
    msg.setMessage(failure.getMessage());
    msg.setStackTrace(failure.getStackTraceString());
    msg.setFatal(failure.isFatal());
    return bean;
  }
View Full Code Here

      if (DUMP_PAYLOAD) {
        System.out.println("<<< " + result);
      }
    } catch (RuntimeException e) {
      e.printStackTrace();
      receiver.onTransportFailure(new ServerFailure(e.getMessage()));
      return;
    }
    receiver.onTransportSuccess(result);
  }
View Full Code Here

* removed in a future version of GWT.</span></p>
*/
@Deprecated
public class DefaultExceptionHandler implements ExceptionHandler {
  public ServerFailure createServerFailure(Throwable throwable) {
    return new ServerFailure("Server Error: "
        + (throwable == null ? null : throwable.getMessage()), null, null, true);
  }
View Full Code Here

      @SuppressWarnings("unchecked")
      Receiver<Object> callback = (Receiver<Object>) invocations.get(0).getReceiver();

      if (!raw.isNull("error")) {
        Splittable error = raw.get("error");
        ServerFailure failure = new ServerFailure(
            error.get("message").asString(), error.get("code").asString(),
            payload, true);
        fail(receiver, failure);
        return;
      }
View Full Code Here

TOP

Related Classes of com.google.gwt.requestfactory.shared.ServerFailure

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.