Example usage for com.google.gwt.user.client.rpc IncompatibleRemoteServiceException IncompatibleRemoteServiceException

List of usage examples for com.google.gwt.user.client.rpc IncompatibleRemoteServiceException IncompatibleRemoteServiceException

Introduction

In this page you can find the example usage for com.google.gwt.user.client.rpc IncompatibleRemoteServiceException IncompatibleRemoteServiceException.

Prototype

public IncompatibleRemoteServiceException() 

Source Link

Document

Constructor used by RPC serialization.

Usage

From source file:cc.alcina.framework.servlet.servlet.CommonRemoteServiceServlet.java

License:Apache License

@Override
public String processCall(String payload) throws SerializationException {
    RPCRequest rpcRequest = null;// w  w w  .  j  a v a 2s.  c o  m
    String threadName = Thread.currentThread().getName();
    try {
        LooseContext.push();
        initUserStateWithCookie(getThreadLocalRequest(), getThreadLocalResponse());
        LooseContext.set(CONTEXT_THREAD_LOCAL_HTTP_REQUEST, getThreadLocalRequest());
        LooseContext.set(CommonPersistenceBase.CONTEXT_CLIENT_IP_ADDRESS,
                ServletLayerUtils.robustGetRemoteAddr(getThreadLocalRequest()));
        LooseContext.set(CommonPersistenceBase.CONTEXT_CLIENT_INSTANCE_ID,
                SessionHelper.getAuthenticatedSessionClientInstanceId(getThreadLocalRequest()));
        rpcRequest = RPC.decodeRequest(payload, this.getClass(), this);
        if (rpcRequest.getSerializationPolicy() instanceof LegacySerializationPolicy) {
            throw new IncompatibleRemoteServiceException();
        }
        getThreadLocalRequest().setAttribute(THRD_LOCAL_RPC_RQ, rpcRequest);
        getThreadLocalRequest().setAttribute(THRD_LOCAL_RPC_PAYLOAD, payload);
        String name = rpcRequest.getMethod().getName();
        RPCRequest f_rpcRequest = rpcRequest;
        Thread.currentThread().setName(Ax.format("gwt-rpc:%s", name));
        onAfterAlcinaAuthentication(name);
        LooseContext.set(CONTEXT_RPC_USER_ID, PermissionsManager.get().getUserId());
        InternalMetrics.get().startTracker(rpcRequest, () -> describeRpcRequest(f_rpcRequest, ""),
                InternalMetricTypeAlcina.client, Thread.currentThread().getName(), () -> true);
        Method method;
        try {
            method = this.getClass().getMethod(name, rpcRequest.getMethod().getParameterTypes());
            if (method.isAnnotationPresent(WebMethod.class)) {
                WebMethod webMethod = method.getAnnotation(WebMethod.class);
                AnnotatedPermissible ap = new AnnotatedPermissible(webMethod.customPermission());
                if (!PermissionsManager.get().isPermissible(ap)) {
                    WebException wex = new WebException("Action not permitted: " + name);
                    logRpcException(wex, LogMessageType.PERMISSIONS_EXCEPTION.toString());
                    return RPC.encodeResponseForFailure(null, wex);
                }
                if (!webMethod.readonlyPermitted()) {
                    AppPersistenceBase.checkNotReadOnly();
                }
            }
        } catch (SecurityException ex) {
            RPC.encodeResponseForFailure(null, ex);
        } catch (NoSuchMethodException ex) {
            RPC.encodeResponseForFailure(null, ex);
        }
        return invokeAndEncodeResponse(rpcRequest);
    } catch (IncompatibleRemoteServiceException ex) {
        getServletContext().log("An IncompatibleRemoteServiceException was thrown while processing this call.",
                ex);
        return RPC.encodeResponseForFailure(null, ex);
    } catch (UnexpectedException ex) {
        logRpcException(ex);
        throw ex;
    } catch (OutOfMemoryError e) {
        handleOom(payload, e);
        throw e;
    } catch (RuntimeException rex) {
        logRpcException(rex);
        throw rex;
    } finally {
        Thread.currentThread().setName(threadName);
        InternalMetrics.get().endTracker(rpcRequest);
        if (TransformManager.hasInstance()) {
            if (CommonUtils
                    .bv((Boolean) getThreadLocalRequest().getAttribute(PUSH_TRANSFORMS_AT_END_OF_REUQEST))) {
                Sx.commit();
            }
            ThreadlocalTransformManager.cast().resetTltm(null);
            LooseContext.pop();
        } else {
            try {
                LooseContext.pop();
            } catch (Exception e) {// squelch, probably webapp undeployed
            }
        }
    }
}