com.google.gwt.http.client.RequestBuilder Java Examples

The following examples show how to use com.google.gwt.http.client.RequestBuilder. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LDRpcRequestBuilder.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
protected RequestBuilder doCreate(String serviceEntryPoint) {
	int timeout = DEFAULT_TIMEOUT;
	if (Session.get().getConfig("gui.rpc.timeout") != null)
		timeout = Integer.parseInt(Session.get().getConfig("gui.rpc.timeout"));
	RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, serviceEntryPoint);
	builder.setTimeoutMillis(timeout * 60 * 1000);
	return builder;
}
 
Example #2
Source File: Module.java    From shortyz with GNU General Public License v3.0 5 votes vote down vote up
@Override
public PuzzleServiceProxy get() {
    return new RetryLocalStorageServiceProxy(service,  new CallStrategy(){

    @Override
    public Request makeRequest(RequestBuilder builder) {
         ShortyzGadget.makePostRequest(builder.getUrl(), builder.getRequestData(), builder.getCallback());
         return new FakeRequest();
    }

});
}
 
Example #3
Source File: PuzzleServiceProxy.java    From shortyz with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Request makeRequest(RequestBuilder builder) {
    try{
        return builder.send();
    } catch(Exception e){
        throw new RuntimeException(e.toString(), e);
    }
}
 
Example #4
Source File: Module.java    From shortyz with GNU General Public License v3.0 5 votes vote down vote up
@Override
public PuzzleServiceProxy get() {
    return new RetryLocalStorageServiceProxy(service,  new CallStrategy(){

    @Override
    public Request makeRequest(RequestBuilder builder) {
         ShortyzWave.makePostRequest(builder.getUrl(), builder.getRequestData(), builder.getCallback());
         return new FakeRequest();
    }

}){

        @Override
        public Request savePuzzle(Long listingId, Puzzle puzzle, final AsyncCallback callback) {
            DeferredCommand.add(new Command(){

                @Override
                public void execute() {
                    callback.onSuccess(null);
                }
                
            });
            return new FakeRequest();
        }

};
}
 
Example #5
Source File: WebServerOperationExecutor.java    From swellrt with Apache License 2.0 5 votes vote down vote up
private RequestBuilder.Method toMethod(ServerOperation.Method method) {
  switch (method) {
  case DELETE:
    return RequestBuilder.DELETE;
  case GET:
    return RequestBuilder.GET;
  case POST:
    return RequestBuilder.POST;
  default:
    return RequestBuilder.GET;
  }
}
 
Example #6
Source File: LogStore.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void doStreamLogFile(final String fileName, final Dispatcher.Channel channel) {
    RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.GET, encode(streamUrl(fileName)));
    requestBuilder.setHeader("Accept", "text/plain");
    requestBuilder.setHeader("Content-Type", "text/plain");
    String bearerToken = DMRHandler.getBearerToken();
    if (bearerToken != null)
        requestBuilder.setHeader("Authorization", "Bearer " + bearerToken);
        
    requestBuilder.setIncludeCredentials(true);
    try {
        // store the request in order to cancel it later
        pendingStreamingRequest = new PendingStreamingRequest(fileName,
                requestBuilder.sendRequest(null, new RequestCallback() {
                    @Override
                    public void onResponseReceived(Request request, Response response) {
                        if (response.getStatusCode() >= 400) {
                            channel.nack(new IllegalStateException("Failed to stream log file " +
                                    fileName + ": " + response.getStatusCode() + " - " +
                                    response.getStatusText()));
                        } else {
                            LogFile newLogFile = new LogFile(fileName, response.getText());
                            newLogFile.setFollow(false);
                            states.put(fileName, newLogFile);
                            activate(newLogFile);
                            channel.ack();
                        }
                    }

                    @Override
                    public void onError(Request request, Throwable exception) {
                        channel.nack(exception);
                    }
                }), channel);
    } catch (RequestException e) {
        channel.nack(e);
    }
}
 
Example #7
Source File: PuzzleServiceProxy.java    From shortyz with GNU General Public License v3.0 4 votes vote down vote up
public Request findPuzzle(Long puzzleId, AsyncCallback<Puzzle> callback){
    RequestBuilder builder = service.findPuzzle(puzzleId, callback);
    return strat.makeRequest(builder);
}
 
Example #8
Source File: PuzzleServiceProxy.java    From shortyz with GNU General Public License v3.0 4 votes vote down vote up
public Request listPuzzles(AsyncCallback<PuzzleDescriptor[]> callback){
    RequestBuilder builder = service.listPuzzles(callback);
    return strat.makeRequest(builder);
}
 
Example #9
Source File: PuzzleServiceProxy.java    From shortyz with GNU General Public License v3.0 4 votes vote down vote up
public Request savePuzzle(Long listingId, Puzzle puzzle, AsyncCallback callback){
    RequestBuilder builder = service.savePuzzle(listingId, puzzle, callback);
    return strat.makeRequest(builder);
}
 
Example #10
Source File: CsrfController.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void securize(RequestBuilder rb) {
	if (token != null) {
		rb.setHeader(header, token);
	}
}
 
Example #11
Source File: Vfs.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
private RequestBuilder createRequestBuilder(RequestBuilder.Method method) {
    return new RequestBuilder(method, BASE_URL);
}
 
Example #12
Source File: PuzzleServiceAsync.java    From shortyz with GNU General Public License v3.0 votes vote down vote up
public RequestBuilder findPuzzle(Long puzzleId, AsyncCallback<Puzzle> callback); 
Example #13
Source File: PuzzleServiceAsync.java    From shortyz with GNU General Public License v3.0 votes vote down vote up
public RequestBuilder listPuzzles(AsyncCallback<PuzzleDescriptor[]> callback); 
Example #14
Source File: PuzzleServiceAsync.java    From shortyz with GNU General Public License v3.0 votes vote down vote up
public RequestBuilder savePuzzle(Long listingId, Puzzle puzzle, AsyncCallback callback); 
Example #15
Source File: PuzzleServiceProxy.java    From shortyz with GNU General Public License v3.0 votes vote down vote up
public Request makeRequest(RequestBuilder builder);