Example usage for com.google.gwt.user.server.rpc RPCRequest getFlags

List of usage examples for com.google.gwt.user.server.rpc RPCRequest getFlags

Introduction

In this page you can find the example usage for com.google.gwt.user.server.rpc RPCRequest getFlags.

Prototype

public int getFlags() 

Source Link

Usage

From source file:com.brightedu.server.BrightServlet.java

License:Apache License

/**
 * Process a call originating from the given request. Uses the
 * {@link RPC#invokeAndEncodeResponse(Object, java.lang.reflect.Method, Object[])}
 * method to do the actual work./*from  ww  w. j  a va 2  s. c  o m*/
 * <p>
 * Subclasses may optionally override this method to handle the payload in
 * any way they desire (by routing the request to a framework component, for
 * instance). The {@link HttpServletRequest} and {@link HttpServletResponse}
 * can be accessed via the {@link #getThreadLocalRequest()} and
 * {@link #getThreadLocalResponse()} methods.
 * </p>
 * This is public so that it can be unit tested easily without HTTP.
 * 
 * @param payload
 *            the UTF-8 request payload
 * @return a string which encodes either the method's return, a checked
 *         exception thrown by the method, or an
 *         {@link IncompatibleRemoteServiceException}
 * @throws SerializationException
 *             if we cannot serialize the response
 * @throws UnexpectedException
 *             if the invocation throws a checked exception that is not
 *             declared in the service method's signature
 * @throws RuntimeException
 *             if the service method throws an unchecked exception (the
 *             exception will be the one thrown by the service)
 */
public String processCall(String payload) throws SerializationException {
    // First, check for possible XSRF situation
    checkPermutationStrongName();

    try {
        RPCRequest rpcRequest = RPC.decodeRequest(payload, delegate.getClass(), this);
        onAfterRequestDeserialized(rpcRequest);
        return RPC.invokeAndEncodeResponse(delegate, rpcRequest.getMethod(), rpcRequest.getParameters(),
                rpcRequest.getSerializationPolicy(), rpcRequest.getFlags());
    } catch (IncompatibleRemoteServiceException ex) {
        log("An IncompatibleRemoteServiceException was thrown while processing this call.", ex);
        return RPC.encodeResponseForFailure(null, ex);
    } catch (RpcTokenException tokenException) {
        log("An RpcTokenException was thrown while processing this call.", tokenException);
        return RPC.encodeResponseForFailure(null, tokenException);
    }
}

From source file:com.google.gwt.sample.dynatable.utils.GWTService.java

License:Apache License

@Override
public String processCall(String payload) throws SerializationException {
    try {// www  .  ja v  a2  s .  c o  m
        RPCRequest rpcRequest = RPC_2_0_1.decodeRequest(payload, this.getClass(), this);

        onAfterRequestDeserialized(rpcRequest);
        return RPC_2_0_1.invokeAndEncodeResponse(this, rpcRequest.getMethod(), rpcRequest.getParameters(),
                rpcRequest.getSerializationPolicy(), rpcRequest.getFlags());

    } catch (IncompatibleRemoteServiceException ex) {
        ex.printStackTrace();
        return RPC.encodeResponseForFailure(null, ex);
    } catch (Exception e) {
        e.printStackTrace();
        return RPC.encodeResponseForFailure(null, e);
    }
}

From source file:com.openforevent.gwt.gwtrpc.server.GwtRpcServiceImpl.java

License:Apache License

public String processCall(String payload) throws SerializationException {
    try {//from ww w . j  a  v  a2s . co m
        RPCRequest rpcRequest = RPC.decodeRequest(payload, this.getClass(), this);
        onAfterRequestDeserialized(rpcRequest);
        return RPC.invokeAndEncodeResponse(this, rpcRequest.getMethod(), rpcRequest.getParameters(),
                rpcRequest.getSerializationPolicy(), rpcRequest.getFlags());
    } catch (IncompatibleRemoteServiceException ex) {
        log("An IncompatibleRemoteServiceException was thrown while processing this call.", ex);
        return RPC.encodeResponseForFailure(null, ex);
    }
}

From source file:com.openforevent.gwt.gwtrpc.util.GwtRpcPayloadUtil.java

License:Apache License

public static HashMap<String, String> getParameters(String requestPayload) {

    HashMap<String, String> parameters = null;

    RPCRequest rpcRequest = RPC.decodeRequest(requestPayload);
    Object[] obj = rpcRequest.getParameters();
    parameters = (HashMap<String, String>) obj[0];

    if (Debug.infoOn()) {
        Debug.logInfo("rpc request method : " + rpcRequest.getMethod(), module);
        Debug.logInfo("rpc request serialization policy : " + rpcRequest.getSerializationPolicy(), module);
        Debug.logInfo("rpc request flags : " + rpcRequest.getFlags(), module);

        Debug.logInfo("rpc request parameters : " + obj, module);
        Debug.logInfo("parameters map : " + parameters, module);
    }/* w w  w .  j a va2  s  . c o  m*/

    return parameters;
}

From source file:com.openforevent.gwt.gwtrpc.util.GwtRpcServletUtil.java

License:Apache License

public String invokeServlet(HttpServletRequest request, HttpServletResponse response, String requestPayload)
        throws InvocationTargetException, IllegalAccessException, InstantiationException, NoSuchMethodException,
        ClassNotFoundException, SerializationException, IOException {

    RemoteService target = getRemoteServiceTarget("com.openforevent.gwt.gwtrpc.server.GwtRpcServiceImpl",
            request, response);/*  w w w. j  a v  a2s. co m*/
    RPCRequest rpcRequest = RPC.decodeRequest(requestPayload, target.getClass(), serializationPolicyProvider);

    String responsePayload = RPC.invokeAndEncodeResponse(target, rpcRequest.getMethod(),
            rpcRequest.getParameters(), serializationPolicy, rpcRequest.getFlags());
    return responsePayload;
}

From source file:com.tasktop.c2c.server.common.web.server.AbstractAutowiredRemoteServiceServlet.java

License:Open Source License

@Override
public String processCall(String payload) throws SerializationException {
    try {//from   w  ww  . j ava 2s  .co  m
        RPCRequest rpcRequest = RPC.decodeRequest(payload, this.getClass(), this);
        onAfterRequestDeserialized(rpcRequest);
        return invokeAndEncodeResponse(rpcRequest.getMethod(), rpcRequest.getParameters(),
                rpcRequest.getSerializationPolicy(), rpcRequest.getFlags());
    } catch (IncompatibleRemoteServiceException ex) {
        log("An IncompatibleRemoteServiceException was thrown while processing this call.", ex);
        return RPC.encodeResponseForFailure(null, ex);
    }
}

From source file:de.itsvs.cwtrpc.controller.RemoteServiceControllerServlet.java

License:Apache License

protected String invokeAndEncodeResponse(HttpServletRequest servletRequest, HttpServletResponse response,
        Object service, RPCRequest rpcRequest)
        throws ServletException, IOException, SecurityException, SerializationException {
    String responsePayload;//from  w  w w . j  a  v a  2 s  .  c  o m

    try {
        final Object invocationResult;

        invocationResult = rpcRequest.getMethod().invoke(service, rpcRequest.getParameters());
        responsePayload = RPC.encodeResponseForSuccess(rpcRequest.getMethod(), invocationResult,
                rpcRequest.getSerializationPolicy(), rpcRequest.getFlags());

        if (CwtRpcUtils.getRpcSessionInvalidationPolicy(servletRequest).isInvalidateAfterInvocation()) {
            invalidateSession(servletRequest);
        }
    } catch (IllegalAccessException e) {
        throw new SecurityException("Illegal access detected when invoking method " + rpcRequest.getMethod()
                + " on service " + service.getClass().getName() + " (as requested by client)", e);
    } catch (IllegalArgumentException e) {
        throw new SecurityException(
                "Illegal argument types detected when invoking method " + rpcRequest.getMethod()
                        + " with arguments \"" + createTypeNameString(rpcRequest.getParameters())
                        + "\" on service " + service.getClass().getName() + " (as requested by client)",
                e);
    } catch (InvocationTargetException e) {
        responsePayload = processInvocationException(servletRequest, service, rpcRequest, e.getCause());
    }

    return responsePayload;
}

From source file:de.itsvs.cwtrpc.controller.RemoteServiceControllerServlet.java

License:Apache License

protected String processExpectedException(HttpServletRequest servletRequest, Object service,
        RPCRequest rpcRequest, Throwable exception)
        throws ServletException, IOException, SerializationException {
    final String responsePayload;

    if (CwtRpcUtils.getRpcSessionInvalidationPolicy(servletRequest).isInvalidateOnExpectedException()) {
        invalidateSession(servletRequest);
    }//from   w  ww  .j av  a2  s . c o m
    responsePayload = RPC.encodeResponseForFailure(rpcRequest.getMethod(), exception,
            rpcRequest.getSerializationPolicy(), rpcRequest.getFlags());

    return responsePayload;
}

From source file:de.itsvs.cwtrpc.security.AbstractRpcSuccessHandler.java

License:Apache License

protected void sendResponse(HttpServletRequest request, HttpServletResponse response,
        Authentication authentication) throws IOException, ServletException {
    final RPCRequest rpcRequest;
    final String responsePayload;

    rpcRequest = AbstractRpcAuthenticationProcessingFilter.getRpcRequest(request);
    if (rpcRequest == null) {
        throw new CwtRpcException("RPC request has not been stored in request ("
                + AbstractRpcAuthenticationProcessingFilter.class.getName() + " must be used)");
    }// w w w .  j  a v a 2 s .co  m

    try {
        addNoCacheResponseHeaders(request, response);
        responsePayload = RPC.encodeResponseForSuccess(rpcRequest.getMethod(),
                getResponse(request, rpcRequest, authentication), rpcRequest.getSerializationPolicy(),
                rpcRequest.getFlags());
        RPCServletUtils.writeResponse(getServletContext(), response, responsePayload, false);
    } catch (SerializationException e) {
        log.error("Serialization error while processing service request", e);
        if (!response.isCommitted()) {
            RPCServletUtils.writeResponseForUnexpectedFailure(getServletContext(), response, e);
        }
    }
}

From source file:fr.putnami.pwt.core.service.server.service.AbstractCommandService.java

License:Open Source License

@Override
protected void processPost(HttpServletRequest request, HttpServletResponse response) throws Throwable {
    try {/* w  ww  . j a  v a 2 s.c o  m*/
        String requestPayload = this.readContent(request);
        RPCRequest rpcRequest = RPC.decodeRequest(requestPayload, getClass(), this);

        String responsePayload = RPC.invokeAndEncodeResponse(this, rpcRequest.getMethod(),
                rpcRequest.getParameters(), rpcRequest.getSerializationPolicy(), rpcRequest.getFlags());

        boolean gzipEncode = RPCServletUtils.acceptsGzipEncoding(request)
                && RPCServletUtils.exceedsUncompressedContentLengthLimit(responsePayload);

        RPCServletUtils.writeResponse(null, response, responsePayload, gzipEncode);
    } catch (Exception e) {
        logger.error("Request processing failed", e);
        throw Throwables.propagate(e);
    }
}