Package com.google.gwt.user.client.rpc

Examples of com.google.gwt.user.client.rpc.StatusCodeException


                }
            } catch (Throwable rbEx) {
              System.out.println("Could not rollback transaction after exception!" + rbEx);
            }
           
            throw new StatusCodeException(500, "Database Error");
        }
    }
View Full Code Here


        if (pendingClose) return;

        if (loadingMessageBox == null) {
            // First load failed
            if (exception instanceof StatusCodeException) {
                final StatusCodeException codeException = (StatusCodeException) exception;
                if (codeException.getStatusCode() == 0) return;
            }
            Window.alert("Cannot inititialize the application : " + exception.getMessage() + "\n" + exception + "\nPlease reload your application");
            return;
        }

        if (communicationErrorHandler != null) {
            if (exception instanceof StatusCodeException) {
                final StatusCodeException statusCodeException = (StatusCodeException) exception;
                communicationErrorHandler.onCommunicationError("" + statusCodeException.getStatusCode(), statusCodeException.getMessage());
            } else {
                communicationErrorHandler.onCommunicationError("x", exception.getMessage());
            }
        } else {
            if (exception instanceof StatusCodeException) {
                final StatusCodeException statusCodeException = (StatusCodeException) exception;
                showCommunicationErrorMessage(statusCodeException);
            } else {
                Window.alert("An unexcepted error occured: " + exception.getMessage() + ". Please check the server logs.");
            }
        }
View Full Code Here

                public void onResponseReceived(final Request request, final Response response) {

                    UIBuilder.getRootEventBus().fireEvent(new HttpResponseReceivedEvent());

                    if (response.getStatusCode() != 200) {
                        onError(request, new StatusCodeException(response.getStatusCode(), response.getStatusText()));
                        return;
                    }

                    if (response.getText() == null || response.getText().isEmpty()) return;
                    callback.onDataReceived(JSONParser.parseStrict(response.getText()).isObject());
View Full Code Here

         logger.error("Method not found " + method);

         // error 500 async call
         asyncCallbackCommand = new Command() {
            public void execute() {
               callback.onFailure(new StatusCodeException(500, "No method found"));
            }
         };
      } else {

         try {
            logger.debug("Invoking " + m + " on " + target.getClass().getName());

            List<RemoteServiceExecutionHandler> handlers = GwtConfig.get().getModuleRunner().getRemoteServiceExecutionHandlers();

            // notify
            for (RemoteServiceExecutionHandler handler : handlers) {
               handler.beforeRpcRequestSerialization(m, subArgs);
            }

            // Serialize objects
            Object[] serializedArgs = new Object[subArgs.length];
            for (int i = 0; i < subArgs.length; i++) {
               try {
                  serializedArgs[i] = serializerHander.serializeUnserialize(subArgs[i]);
               } catch (Exception e) {
                  throw new GwtTestRpcException("Error while serializing argument " + i
                           + " of type " + subArgs[i].getClass().getName() + " in method "
                           + method.getDeclaringClass().getSimpleName() + "." + method.getName()
                           + "(..)", e);
               }
            }

            // notify
            for (RemoteServiceExecutionHandler handler : handlers) {
               handler.beforeRpcRequestSerialization(m, serializedArgs);
            }

            AbstractRemoteServiceServletPatcher.currentCalledMethod = m;

            // notify
            for (RemoteServiceExecutionHandler handler : handlers) {
               handler.beforeRpcMethodExecution(m, serializedArgs);
            }

            Object resultObject = m.invoke(target, serializedArgs);

            // notify
            for (RemoteServiceExecutionHandler handler : handlers) {
               handler.afterRpcMethodExecution(m, resultObject);
            }

            Object returnObject;
            try {
               // notify
               for (RemoteServiceExecutionHandler handler : handlers) {
                  handler.beforeRpcResponseSerialization(m, resultObject);
               }
               returnObject = serializerHander.serializeUnserialize(resultObject);
               // notify
               for (RemoteServiceExecutionHandler handler : handlers) {
                  handler.afterRpcResponseSerialization(m, returnObject);
               }
            } catch (Exception e) {
               throw new GwtTestRpcException("Error while serializing object of type "
                        + resultObject.getClass().getName()
                        + " which was returned from RPC Service "
                        + method.getDeclaringClass().getSimpleName() + "." + method.getName()
                        + "(..)", e);
            }

            final Object o = returnObject;

            // success async call
            asyncCallbackCommand = new Command() {
               public void execute() {
                  logger.debug("Result of " + m.getName() + " : " + o);
                  callback.onSuccess(o);
               }
            };

         } catch (final InvocationTargetException e) {
            if (GwtTestException.class.isInstance(e.getCause())) {
               throw (GwtTestException) e.getCause();
            }
            asyncCallbackCommand = new Command() {
               public void execute() {
                  logger.info("Exception when invoking service throw to handler " + e.getMessage());
                  exceptionHandler.handle(e.getCause(), callback);
               }
            };
         } catch (final IllegalAccessException e) {
            asyncCallbackCommand = new Command() {
               public void execute() {
                  logger.error("GWT RPC exception : " + e.toString(), e);
                  callback.onFailure(new StatusCodeException(500, e.toString()));
               }
            };
         } catch (final IllegalArgumentException e) {
            asyncCallbackCommand = new Command() {
               public void execute() {
                  logger.error("GWT RPC exception : " + e.toString(), e);
                  callback.onFailure(new StatusCodeException(500, e.toString()));
               }
            };
         }

      }
View Full Code Here

      boolean toss = statsContext.isStatsAvailable()
          && statsContext.stats(
              statsContext.bytesStat(methodName, encodedResponse.length(), "responseReceived"));

      if (statusCode != Response.SC_OK) {
        caught = new StatusCodeException(statusCode, encodedResponse);
      } else if (encodedResponse == null) {
        // This can happen if the XHR is interrupted by the server dying
        caught = new InvocationException("No response payload");
      } else if (RemoteServiceProxy.isReturnValue(encodedResponse)) {
        result = (T) responseReader.read(streamFactory.createStreamReader(encodedResponse));
View Full Code Here

      boolean toss = RemoteServiceProxy.isStatsAvailable()
          && RemoteServiceProxy.stats(RemoteServiceProxy.bytesStat(methodName,
          requestId, encodedResponse.length(), "responseReceived"));

      if (statusCode != Response.SC_OK) {
        caught = new StatusCodeException(statusCode, encodedResponse);
      } else if (encodedResponse == null) {
        // This can happen if the XHR is interrupted by the server dying
        caught = new InvocationException("No response payload");
      } else if (RemoteServiceProxy.isReturnValue(encodedResponse)) {
        result = (T) responseReader.read(streamFactory.createStreamReader(encodedResponse));
View Full Code Here

      boolean toss = RemoteServiceProxy.isStatsAvailable()
          && RemoteServiceProxy.stats(RemoteServiceProxy.bytesStat(methodName,
              requestId, encodedResponse.length(), "responseReceived"));

      if (statusCode != Response.SC_OK) {
        caught = new StatusCodeException(statusCode, encodedResponse);
      } else if (encodedResponse == null) {
        // This can happen if the XHR is interrupted by the server dying
        caught = new InvocationException("No response payload");
      } else {
        result = (T) streamFactory.createStreamReader(encodedResponse).readObject();
View Full Code Here

 
  private void onReceiving(int statusCode, String responseText, boolean connected) {
    if (statusCode != Response.SC_OK) {
      if (!connected) {
        super.disconnect();
        listener.onError(new StatusCodeException(statusCode, responseText), connected);
      }
    }
    else {
      int index = responseText.lastIndexOf(SEPARATOR);
      if (index > read) {
View Full Code Here

      listener.onError(new CometException("Unexpected disconnection"), false);
    }
  }
 
  private void onError(int statusCode, String message) {
    listener.onError(new StatusCodeException(statusCode, message), false);
  }
View Full Code Here

            }
            else {
              statusCode = Integer.parseInt(message.substring(0, index));
              statusMessage = unescape(message.substring(index + 1));
            }
            listener.onError(new StatusCodeException(statusCode, statusMessage), false);
          }
          catch (NumberFormatException e) {
            listener.onError(new CometException("Unexpected status code: " + message), false);
          }
          break;
View Full Code Here

TOP

Related Classes of com.google.gwt.user.client.rpc.StatusCodeException

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.