Example usage for com.google.gwt.user.server.rpc RPCServletUtils readContentAsGwtRpc

List of usage examples for com.google.gwt.user.server.rpc RPCServletUtils readContentAsGwtRpc

Introduction

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

Prototype

public static String readContentAsGwtRpc(HttpServletRequest request) throws IOException, ServletException 

Source Link

Document

Returns the content of an HttpServletRequest , after verifying a <code>gwt/x-gwt-rpc; charset=utf-8</code> content type.

Usage

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

License:Apache License

public static String getRequestPayload(HttpServletRequest request) throws ServletException, IOException {

    //String requestPayload = RPCServletUtils.readContentAsUtf8(request, true);
    String requestPayload = RPCServletUtils.readContentAsGwtRpc(request);

    if (Debug.infoOn()) {
        Debug.logInfo("request : " + request.getRequestURI(), module);
        Debug.logInfo("requestPayload : " + requestPayload, module);
    }/*from w  w  w.jav a2s  . co m*/

    return requestPayload;
}

From source file:de.itsvs.cwtrpc.core.CwtRpcUtils.java

License:Apache License

public static String readContent(HttpServletRequest request)
        throws ServletException, IOException, SecurityException {
    String payload;//from  w w  w  . j a va  2  s.  co m

    /*
     * Content can only be read once from servlet request. In order to
     * access it multiple times the content must be stored in request after
     * it has been read.
     */
    payload = (String) request.getAttribute(GWT_RPC_REQUEST_CONTENT_ATTR_NAME);
    if (payload == null) {
        if (!containsStrongName(request)) {
            throw new SecurityException("Request does not contain required strong name header");
        }
        payload = RPCServletUtils.readContentAsGwtRpc(request);
        request.setAttribute(GWT_RPC_REQUEST_CONTENT_ATTR_NAME, payload);
    }

    return payload;
}

From source file:fr.putnami.pwt.plugin.spring.rpc.server.controller.CommandController.java

License:Open Source License

@RequestMapping(value = "/commandService", method = RequestMethod.POST)
public void processPostRpc(HttpServletRequest request, HttpServletResponse response) throws Throwable {
    try {//ww  w  .j a  v  a2  s  .  c  om
        String requestPayload = RPCServletUtils.readContentAsGwtRpc(request);
        RPCRequest rpcRequest = RPC.decodeRequest(requestPayload, CommandService.class, this);

        String responsePayload = RPC.invokeAndEncodeResponse(commandService, 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) {
        this.logger.error("Request processing failed", e);
        throw Throwables.propagate(e);
    }
}