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

The following are top voted examples for showing how to use com.google.gwt.http.client.RequestBuilder. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: LAS   File: Correlation.java   View source code 7 votes vote down vote up
@Override
public void onCancel(CancelEvent event) {
	if (event.getID().equals("Correlation")) {
		currentURL = currentURL + "&cancel=true";
		RequestBuilder sendRequest = new RequestBuilder(
				RequestBuilder.GET, currentURL);
		try {

			lasAnnotationsPanel
					.setError("Fetching plot annotations...");
			sendRequest.sendRequest(null, lasRequestCallback);
		} catch (RequestException e) {
			Window.alert("Unable to cancel request.");
		}
	}
}
 
Example 2
Project: WebConsole   File: JSONControllerConnector.java   View source code 6 votes vote down vote up
private void doJsonRequest(String url, String username, String password, JSONControllerCallback callback, Integer timeout) {
	RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, url);
	Request request = null;
	
	// Add accept header
	builder.setHeader("Accept", "application/json");
	
	if (username != null && username.length() > 0) {
		if (password == null) password = "";
		
		// Add authentication header
		String authStr = username + ":" + password;
		String authEnc = "Basic " + BrowserUtils.base64Encode(authStr);
		builder.setHeader("Authorization", authEnc);
	}
	
	builder.setCallback(callback);
	
	if (timeout != null) {
		builder.setTimeoutMillis(timeout);
	}
	
   try {
 		request = builder.send();
   } catch (RequestException e) {
 		callback.onError(request, e);
   }
}
 
Example 3
Project: LAS   File: OutputPanel.java   View source code 6 votes vote down vote up
@Override
public void onCancel(CancelEvent event) {
    if (event.getID().equals(ID)) {
        currentURL = currentURL + "&cancel=true";
        RequestBuilder sendRequest = new RequestBuilder(RequestBuilder.GET, currentURL);
        try {

            lasAnnotationsPanel.setError("Fetching plot annotations...");
            updating = true;
            // sendRequest.sendRequest(null, 33Callback);
            // Using LASRequestEvent Controller so a cancel in one
            // OutputPanel cancels related requests too
            LASRequestEvent lasRequestEvent = new LASRequestEvent(sendRequest, "lasRequestCallback", getName());
            eventBus.fireEventFromSource(lasRequestEvent, thisOutputPanel);
            // } catch (RequestException e) {
        } catch (Exception e) {
            Window.alert("Unable to cancel request.");
        }
    }
}
 
Example 4
Project: LAS   File: CruiseIconWidget.java   View source code 6 votes vote down vote up
public void init(LASRequest request, String cruiseid) {
  	message.setVisible(false);
  	request.setOperation("Cruise_List", "v7");
  	List<Map<String, String>> c = request.getVariableConstraints();
  	for (Iterator cIt = c.iterator(); cIt.hasNext();) {
	Map<String, String> map = (Map<String, String>) cIt.next();
	String varid = map.get("varID");
	if ( varid.equals(cruiseid)) {
		
	} else {
		
	}
}
String url = Util.getProductServer()+"?xml="+URL.encode(request.toString());
  	RequestBuilder sendRequest = new RequestBuilder(RequestBuilder.GET, UriUtils.sanitizeUri(url));
try {
	sendRequest.sendRequest(null, iconListRequestCallback);
} catch (RequestException e) {
	message.setVisible(true);
	message.setHTML("Unable to icon list");
}
  }
 
Example 5
Project: LAS   File: LASRequestEvent.java   View source code 6 votes vote down vote up
/**
 * @param requestBuilder
 *            the requestBuilder to set
 */
void setRequestBuilder(RequestBuilder requestBuilder) {
	this.requestBuilder = requestBuilder;
	this.url = this.requestBuilder.getUrl();
	String httpMethod = this.requestBuilder.getHTTPMethod();
	if (RequestBuilder.GET.toString().equalsIgnoreCase(httpMethod)) {
		this.method = RequestBuilder.GET;
	} else if (RequestBuilder.POST.toString().equalsIgnoreCase(httpMethod)) {
		this.method = RequestBuilder.POST;
	} else if (RequestBuilder.DELETE.toString().equalsIgnoreCase(httpMethod)) {
		this.method = RequestBuilder.DELETE;
	} else if (RequestBuilder.HEAD.toString().equalsIgnoreCase(httpMethod)) {
		this.method = RequestBuilder.HEAD;
	} else if (RequestBuilder.PUT.toString().equalsIgnoreCase(httpMethod)) {
		this.method = RequestBuilder.PUT;
	}
}
 
Example 6
Project: gwt-syncproxy   File: RunTimeSerializationErrorsTest.java   View source code 6 votes vote down vote up
public void testBadSerialization3() throws RequestException {
	final boolean[] callbackFired = new boolean[] { false };

	RequestBuilder rb = getService().echoRequestBuilder(
			new MixedSerializable.NonSerializableSub(),
			new AsyncCallback<MixedSerializable>() {
				@Override
				public void onFailure(Throwable caught) {
					assertFalse("callback fired twice", callbackFired[0]);
					callbackFired[0] = true;
				}

				@Override
				public void onSuccess(MixedSerializable result) {
					fail("RPC request should have failed");
				}
			});

	assertFalse(callbackFired[0]); // should fail when send() is called
	rb.send();
	assertTrue(callbackFired[0]); // should have happened now
}
 
Example 7
Project: gwt-syncproxy   File: RemoteServiceServletTest.java   View source code 6 votes vote down vote up
public void testManualSend() throws RequestException {
	RemoteServiceServletTestServiceAsync service = getAsyncService();

	delayTestFinishForRpc();

	RequestBuilder builder = service
			.testExpectCustomHeader(new AsyncCallback<Void>() {

				@Override
				public void onFailure(Throwable caught) {
					TestSetValidator.rethrowException(caught);
				}

				@Override
				public void onSuccess(Void result) {
					assertTrue(!RemoteServiceServletTest.this.req
							.isPending());
					finishTest();
				}
			});

	builder.setHeader("X-Custom-Header", "true");
	this.req = builder.send();
	assertTrue(this.req.isPending());
}
 
Example 8
Project: gwt-syncproxy   File: RunTimeSerializationErrorsTest.java   View source code 6 votes vote down vote up
public void testBadSerialization3() throws RequestException {
	final boolean[] callbackFired = new boolean[] { false };

	RequestBuilder rb = getService().echoRequestBuilder(
			new MixedSerializable.NonSerializableSub(),
			new AsyncCallback<MixedSerializable>() {
				@Override
				public void onFailure(Throwable caught) {
					assertFalse("callback fired twice", callbackFired[0]);
					callbackFired[0] = true;
				}

				@Override
				public void onSuccess(MixedSerializable result) {
					fail("RPC request should have failed");
				}
			});

	assertFalse(callbackFired[0]); // should fail when send() is called
	rb.send();
	assertTrue(callbackFired[0]); // should have happened now
}
 
Example 9
Project: gwt-syncproxy   File: RemoteServiceServletTest.java   View source code 6 votes vote down vote up
public void testManualSend() throws RequestException {
	fail("Request Builder Not Supported");
	final RemoteServiceServletTestServiceAsync service = getAsyncService();

	delayTestFinishForRpc();

	setTask(new AsyncTask<Void, Void, Void>() {

		@Override
		protected Void doInBackground(Void... arg0) {
			RequestBuilder builder = service
					.testExpectCustomHeader(new AsyncCallback<Void>() {

						@Override
						public void onFailure(Throwable caught) {
							TestSetValidator.rethrowException(caught);
						}

						@Override
						public void onSuccess(Void result) {
							assertTrue(!RemoteServiceServletTest.this.req
									.isPending());
							finishTest();
						}
					});
			builder.setHeader("X-Custom-Header", "true");
			try {
				RemoteServiceServletTest.this.req = builder.send();
			} catch (RequestException e) {
				throw new RuntimeException(e);
			}
			assertTrue(RemoteServiceServletTest.this.req.isPending());
			return null;
		}
	});
}
 
Example 10
Project: che   File: ProjectServiceClientTest.java   View source code 6 votes vote down vote up
@Test
public void shouldEncodeUrlAndUpdateProject() {
  when(requestFactory.createRequest(
          any(RequestBuilder.Method.class), anyString(), any(ProjectConfig.class), anyBoolean()))
      .thenReturn(asyncRequest);
  when(prjConfig1.getPath()).thenReturn(TEXT);

  client.updateProject(prjConfig1);

  verify(requestFactory).createRequest(eq(PUT), anyString(), eq(prjConfig1), eq(false));
  verify(asyncRequest).header(CONTENT_TYPE, APPLICATION_JSON);
  verify(asyncRequest).header(ACCEPT, APPLICATION_JSON);
  verify(loaderFactory).newLoader("Updating project...");
  verify(asyncRequest).loader(messageLoader);
  verify(unmarshaller).newUnmarshaller(ProjectConfigDto.class);
  verify(asyncRequest).send(unmarshallablePrjConf);
}
 
Example 11
Project: onecmdb   File: MDRStartWidget.java   View source code 6 votes vote down vote up
public void doStop() {
 for (TabItem item : advanced.getItems()) {
	 final CIModel model = (CIModel)item.getData("model");

	 // Do a HTTP request..
	 RequestBuilder req = new RequestBuilder(RequestBuilder.GET, getStopURL(model));

	 try {
		 Info.display("Stop", "Send stop to " + model.getDisplayName());
		 req.sendRequest(null, new RequestCallback() {

			 public void onResponseReceived(Request request, Response response) {
				 Info.display("Stop", "COMPLETED. Stop sent to " + model.getDisplayName());
			 }

			 public void onError(Request arg0, Throwable arg1) {
				 Info.display("Stop", "FAILED. to stop " + model.getDisplayName());
			 }
		 });

	 } catch (RequestException e) {
		 Info.display("Stop", "ERROR. to stop " + model.getDisplayName());
	 } 
 }
}
 
Example 12
Project: jaxmpp-android   File: BoshConnector.java   View source code 6 votes vote down vote up
public BoshConnector(Context context) {
	super(context);

	String u = context.getSessionObject().getProperty(AbstractBoshConnector.BOSH_SERVICE_URL_KEY);

	Boolean ignoreServerHost = context.getSessionObject().getProperty(BOSH_IGNORE_SERVER_HOST);
	if (ignoreServerHost == null || !ignoreServerHost) {
		// if we support change of destination by host attribute sent by server
		// then parse url to get current hostname
		MatchResult result = URL_PARSER.exec(u);
		host = result.getGroup(2);
	}
	requestBuilder = new RequestBuilder(RequestBuilder.POST, u);
	// in Chrome following line causes error (Connection: close is not
	// allowed in new spec)
	// requestBuilder.setHeader("Connection", "close");
}
 
Example 13
Project: firefly   File: ServiceLocator.java   View source code 6 votes vote down vote up
@Override
protected void doFinish(RequestBuilder rb) {
    super.doFinish(rb);

    if (checkUserInfo) {
        String userToken = Cookies.getCookie(LoginManagerImpl.COOKIE_USER_KEY);
        userToken = userToken == null ? "" : userToken.replaceAll("\"", "");
        String user = userToken.contains("/") ? userToken.split("/", 2)[1] : null;
        LoginManager loginManager= Application.getInstance().getLoginManager();
        if (user != null && loginManager!=null && loginManager.getLoginInfo()!=null) {
            if (!loginManager.getLoginInfo().getLoginName().equals(user)) {
                loginManager.refreshUserInfo(true);
            }
        }
    }
}
 
Example 14
Project: firefly   File: HtmlRegionLoader.java   View source code 6 votes vote down vote up
public void load(String url, final String regionName) {
    RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, url);
    try {
        builder.sendRequest(null, new RequestCallback(){
            public void onResponseReceived(com.google.gwt.http.client.Request req, Response res) {
                updateHtml(res.getText(), regionName);
            }

            public void onError(com.google.gwt.http.client.Request request, Throwable exception) {
            }
        });
    } catch (RequestException e) {
        e.printStackTrace();
    }

}
 
Example 15
Project: platypus-js   File: AppClient.java   View source code 6 votes vote down vote up
public Cancellable requestLogout(final Callback<XMLHttpRequest, XMLHttpRequest> aCallback) throws Exception {
	String query = param(PlatypusHttpRequestParams.TYPE, String.valueOf(Requests.rqLogout));
	return startApiRequest(null, query, null, RequestBuilder.GET, null, new CallbackAdapter<XMLHttpRequest, XMLHttpRequest>() {

		@Override
		protected void doWork(XMLHttpRequest aResult) throws Exception {
			principal = null;
			aCallback.onSuccess(aResult);
		}

		@Override
		public void onFailure(XMLHttpRequest reason) {
			aCallback.onFailure(reason);
		}

	});
}
 
Example 16
Project: platypus-js   File: AppClient.java   View source code 6 votes vote down vote up
public void startDownloadRequest(String aUrlPrefix, final int aRequestType, Map<String, String> aParams, RequestBuilder.Method aMethod) throws Exception {
	final Frame frame = new Frame();
	frame.setVisible(false);

	frame.addLoadHandler(new LoadHandler() {

		@Override
		public void onLoad(LoadEvent event) {
			Timer timer = new Timer() {

				@Override
				public void run() {
					frame.removeFromParent();
				}
			};
			timer.schedule(2000);
		}
	});
	String query = "";
	for (Map.Entry<String, String> ent : aParams.entrySet()) {
		query += param(ent.getKey(), ent.getValue()) + "&";
	}
	query += param(PlatypusHttpRequestParams.TYPE, String.valueOf(aRequestType));
	frame.setUrl(apiUrl + aUrlPrefix + "?" + query);
	RootPanel.get().add(frame);
}
 
Example 17
Project: platypus-js   File: AppClient.java   View source code 6 votes vote down vote up
public XMLHttpRequest2 syncRequest(String aUrl, ResponseType aResponseType) throws Exception {
	final XMLHttpRequest2 req = syncRequest(aUrl, aResponseType, null, RequestBuilder.GET);
	if (req.getStatus() == Response.SC_OK)
		return req;
	else
		throw new Exception(req.getStatus() + " " + req.getStatusText());
}
 
Example 18
Project: platypus-js   File: AppClient.java   View source code 6 votes vote down vote up
public XMLHttpRequest2 syncRequest(String aUrl, ResponseType aResponseType, String aBody, RequestBuilder.Method aMethod) throws Exception {
	final XMLHttpRequest2 req = XMLHttpRequest.create().<XMLHttpRequest2> cast();
	aUrl = Loader.URL_QUERY_PROCESSOR.process(aUrl);
	req.open(aMethod.toString(), aUrl, false);
	interceptRequest(req);
	/*
	 * Since W3C standard about sync XmlHttpRequest and response type. if
	 * (aResponseType != null && aResponseType != ResponseType.Default)
	 * req.setResponseType(aResponseType);
	 */
	req.setRequestHeader("Pragma", "no-cache");
	if (aBody != null)
		req.send(aBody);
	else
		req.send();
	if (req.getStatus() == Response.SC_OK)
		return req;
	else
		throw new Exception(req.getStatus() + " " + req.getStatusText());
}
 
Example 19
Project: turbogwt-http   File: RequestImpl.java   View source code 6 votes vote down vote up
private void dispatch(RequestBuilder.Method method, RequestCallback callback) {
    ensureHeaders();

    // Execute filters on this request
    final List<RequestFilter> filters = filterManager.getRequestFilters();
    for (RequestFilter filter : filters) {
        filter.filter(this);
    }

    String body = serializePayload();

    ServerConnection connection = server.getConnection();

    try {
        connection.sendRequest(timeout, user, password, headers, method, uri, body, callback);
    } catch (final RequestException e) {
        throw new RequestDispatchException("It was not possible to dispatch the request.", e);
    }
}
 
Example 20
Project: turbogwt-http   File: ServerConnectionImpl.java   View source code 6 votes vote down vote up
@Override
public void sendRequest(int timeout, @Nullable String user, @Nullable String password, @Nullable Headers headers,
                        RequestBuilder.Method method, String url, String data, RequestCallback callback)
        throws RequestException {
    final RequestBuilder requestBuilder = new RequestBuilder(method, url);
    if (timeout > 0) requestBuilder.setTimeoutMillis(timeout);
    if (user != null) requestBuilder.setUser(user);
    if (password != null) requestBuilder.setPassword(password);
    if (user != null && password != null) requestBuilder.setIncludeCredentials(true);
    if (headers != null) {
        for (Header header : headers) {
            requestBuilder.setHeader(header.getName(), header.getValue());
        }
    }
    requestBuilder.sendRequest(data, callback);
}
 
Example 21
Project: OneCMDBwithMaven   File: MDRStartWidget.java   View source code 6 votes vote down vote up
public void doStop() {
 for (TabItem item : advanced.getItems()) {
	 final CIModel model = (CIModel)item.getData("model");

	 // Do a HTTP request..
	 RequestBuilder req = new RequestBuilder(RequestBuilder.GET, getStopURL(model));

	 try {
		 Info.display("Stop", "Send stop to " + model.getDisplayName());
		 req.sendRequest(null, new RequestCallback() {

			 public void onResponseReceived(Request request, Response response) {
				 Info.display("Stop", "COMPLETED. Stop sent to " + model.getDisplayName());
			 }

			 public void onError(Request arg0, Throwable arg1) {
				 Info.display("Stop", "FAILED. to stop " + model.getDisplayName());
			 }
		 });

	 } catch (RequestException e) {
		 Info.display("Stop", "ERROR. to stop " + model.getDisplayName());
	 } 
 }
}
 
Example 22
Project: hexa.tools   File: RPCBatchRequestSender.java   View source code 6 votes vote down vote up
private RequestBuilder buildMultipart( String name, String value )
{
	String boundary = "AJAX------" + Math.random() + "" + new Date().getTime();

	RequestBuilder builderPost = new RequestBuilder( RequestBuilder.POST, url );
	builderPost.setHeader( "Content-Type", "multipart/form-data; charset=utf-8; boundary=" + boundary );
	builderPost.setCallback( requestCallback );

	String CRLF = "\r\n";
	String data = "--" + boundary + CRLF;
	data += "--" + boundary + CRLF;

	data += "Content-Disposition: form-data; ";
	data += "name=\"" + name + "\"" + CRLF + CRLF;
	data += value + CRLF;
	data += "--" + boundary + "--" + CRLF;

	builderPost.setRequestData( data );

	return builderPost;
}
 
Example 23
Project: ineform   File: RestDataConnectorComplexTest.java   View source code 6 votes vote down vote up
private void prepareRequestBuilder(
    RequestBuilder requestBuilder,
    String responseText,
    int statusCode) throws Exception {
    final Response response = mock(Response.class);
    when(response.getStatusCode()).thenReturn(statusCode);
    when(response.getText()).thenReturn(responseText);

    when(requestBuilder.sendRequest(anyString(), any(RequestCallback.class)))
        .thenAnswer(new Answer<Request>() {

            @Override
            public Request answer(InvocationOnMock invocation) throws Throwable {
                ((RequestCallback) invocation.getArguments()[1])
                    .onResponseReceived(null, response);
                return null;
            }
        });
}
 
Example 24
Project: droopy   File: Main.java   View source code 6 votes vote down vote up
private void ajax(final String resource, final String body,
                  final AjaxCallback callback) {
  final boolean has_body = body != null;
  final RequestBuilder builder =
    new RequestBuilder(has_body ? RequestBuilder.POST : RequestBuilder.GET,
                       server + resource);
  // Doesn't work on Chrome due to ES bug #828.
  //if (has_body) {
  //  builder.setHeader("Content-Type", "application/json");
  //}
  try {
    builder.sendRequest(body, callback);
  } catch (RequestException e) {
    status.setText("Failed to setup AJAX call to " + server + resource
                   + ": " + e);
  }
}
 
Example 25
Project: gwt-rf-queue   File: QosRequestTransport.java   View source code 6 votes vote down vote up
private void sendBatch(String payload, List<BatchedRequest> currentBatch) {
    // XXX use super.send?
    RequestBuilder builder = createRequestBuilder();
    configureRequestBuilder(builder);

    builder.setRequestData(payload);
    builder.setCallback(createRequestCallbackBatch(currentBatch));

    try {
        wireLogger.finest("Sending fire request");
        builder.send();
    } catch (RequestException e) {
        wireLogger.log(Level.SEVERE, " (" + e.getMessage()
         + ")", e);
    }
}
 
Example 26
Project: empiria.player   File: RequestWrapper.java   View source code 5 votes vote down vote up
public void get(String url, RequestCallback callback) {
    try {
        new RequestBuilder(RequestBuilder.GET, url).sendRequest("", callback);
    } catch (RequestException e) {
        logger.error(e);
    }
}
 
Example 27
Project: LAS   File: LASAnnotationsButton.java   View source code 5 votes vote down vote up
public void setAnnotationsHTMLURL(String url) {
	RequestBuilder sendRequest = new RequestBuilder(RequestBuilder.GET, url);
	try {
		sendRequest.sendRequest(null, annotationsHTMLCallback);
	} catch (RequestException e) {
		
	}
}
 
Example 28
Project: LAS   File: LASAnnotationsPanel.java   View source code 5 votes vote down vote up
public void setAnnotationsHTMLURL(String url) {
	RequestBuilder sendRequest = new RequestBuilder(RequestBuilder.GET, UriUtils.sanitizeUri(url));
	try {
		sendRequest.sendRequest(null, annotationsHTMLCallback);
	} catch (RequestException e) {
		e.printStackTrace();
	}
}
 
Example 29
Project: LAS   File: PrintPanel.java   View source code 5 votes vote down vote up
public PrintPanel(String url) {
	RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, url);
	initWidget(panel);
	try {
		builder.sendRequest(null, fillPanelCallback);
	} catch (RequestException e) {
		HTMLPanel html = new HTMLPanel("<b>Unable to retrieve image.</b>");		
		panel.add(html);
	}
}
 
Example 30
Project: LAS   File: CruiseIconWidget.java   View source code 5 votes vote down vote up
public void init(String iconurl) {
	RequestBuilder sendRequest = new RequestBuilder(RequestBuilder.GET, UriUtils.sanitizeUri(iconurl));
	try {
		sendRequest.sendRequest(null, iconCallback);
	} catch (RequestException e) {
		message.setVisible(true);
		message.setHTML("Unable to get icon list.");
	}
}
 
Example 31
Project: LAS   File: SimplePropPropViewer.java   View source code 5 votes vote down vote up
private void updatePlot(boolean addHistory, boolean cache) {
    // TODO Before submitting...

    
    setConstraints();
    
    //TODO this should wait until the result comes back and is good and should be an event, right?
    update.removeStyleDependentName("APPLY-NEEDED");

    lasAnnotationsPanel.setError("Fetching plot...");

    spin.setPopupPosition(outputPanel.getAbsoluteLeft(), outputPanel.getAbsoluteTop());
    spin.show();

    makeRequest(true);
   
    imageCanvas = Canvas.createIfSupported();
    drawingCanvas = Canvas.createIfSupported();

    
    
    if (imageCanvas != null) {

        canvasDiv.add(imageCanvas, 0, 0);
        canvasDiv.add(drawingCanvas, 0, 0);
        outputPanel.setWidget(1, 0, canvasDiv);
        imageCanvasContext = imageCanvas.getContext2d();
        drawingCanvasContext = drawingCanvas.getContext2d();
        
    } else {
        outputPanel.setWidget(1, 0 , new HTML(""));
        Window.alert("You are accessing this site with an older, no longer supported browser. "
                + "Some or all features of this site will not work correctly using your browser. " + "Recommended browsers include these or higher versions of these: "
                + "IE 9.0   FF 17.0    Chorme 23.0    Safari 5.1");
    }

    String url = Util.getProductServer() + "?xml=" + URL.encode(lasRequest.toString());

    currentURL = url;
    
    if ( cache ) {
        lasRequest.setProperty("product_server", "use_cache", "true");
    } else {
        lasRequest.setProperty("product_server", "use_cache", "false");
    }

    if (addHistory) {
        String x = lasRequest.toString();
        pushHistory(x);
    }

    RequestBuilder sendRequest = new RequestBuilder(RequestBuilder.GET, url);
    try {
        sendRequest.sendRequest(null, lasRequestCallback);
    } catch (RequestException e) {
        HTML error = new HTML(e.toString());
        outputPanel.setWidget(2, 0, error);
    }

}
 
Example 32
Project: LAS   File: SimplePropPropViewer.java   View source code 5 votes vote down vote up
@Override
public void onCancel(CancelEvent event) {
    if (event.getID().equals("Correlation")) {
        currentURL = currentURL + "&cancel=true";
        RequestBuilder sendRequest = new RequestBuilder(RequestBuilder.GET, currentURL);
        try {

            lasAnnotationsPanel.setError("Fetching plot annotations...");
            sendRequest.sendRequest(null, lasRequestCallback);
        } catch (RequestException e) {
            Window.alert("Unable to cancel request.");
        }
    }
}
 
Example 33
Project: LAS   File: LASRequestEvent.java   View source code 5 votes vote down vote up
public LASRequestEvent(RequestBuilder requestBuilder,
		String requestCallbackObjectName, String sourceName) {
	this.requestBuilder = requestBuilder;
	this.requestCallbackObjectName = requestCallbackObjectName;
	this.url = requestBuilder.getUrl();
	this.sourceName = sourceName;
}
 
Example 34
Project: LAS   File: LASRequestEvent.java   View source code 5 votes vote down vote up
public LASRequestEvent(String url, RequestBuilder.Method method,
		String requestCallbackObjectName, String sourceName) {
	this.url = url;
	this.method = method;
	this.requestCallbackObjectName = requestCallbackObjectName;
	this.requestBuilder = new RequestBuilder(this.method, this.url);
	this.sourceName = sourceName;
}
 
Example 35
Project: LAS   File: ThumbnailPropProp.java   View source code 5 votes vote down vote up
private void sendPlot(LASRequest lr0) {
    currentRequest = lr0;
    String url = Util.getProductServer() + "?xml=" + URL.encode(lr0.toString());
    RequestBuilder sendRequest = new RequestBuilder(RequestBuilder.GET, url);
    try {
        sendRequest.sendRequest(null, lasRequestCallback);
    } catch (RequestException e) {
        Window.alert("Unable to make plot requests.");
    }
}
 
Example 36
Project: gwt-syncproxy   File: RemoteServiceServletTest.java   View source code 5 votes vote down vote up
/**
 * Send request without the permutation strong name and expect a
 * SecurityException. This tests
 * RemoteServiceServlet#checkPermutationStrongName.
 */
public void testRequestWithoutStrongNameHeader() {
	RemoteServiceServletTestServiceAsync service = getAsyncService();
	((ServiceDefTarget) service)
	.setRpcRequestBuilder(new RpcRequestBuilder() {
		/**
		 * Copied from base class.
		 */
		@Override
		protected void doFinish(RequestBuilder rb) {
			// Don't set permutation strong name
			rb.setHeader(MODULE_BASE_HEADER, GWT.getModuleBaseURL());
		}

	});

	delayTestFinishForRpc();
	service.test(new AsyncCallback<Void>() {
		@Override
		public void onFailure(Throwable caught) {
			assertTrue(caught instanceof StatusCodeException);
			assertEquals(500,
					((StatusCodeException) caught).getStatusCode());
			finishTest();
		}

		@Override
		public void onSuccess(Void result) {
			fail();
		}
	});
}
 
Example 37
Project: gwt-syncproxy   File: RemoteServiceServletTest.java   View source code 5 votes vote down vote up
/**
 * Send request without the permutation strong name and expect a
 * SecurityException. This tests
 * RemoteServiceServlet#checkPermutationStrongName.
 */
public void testRequestWithoutStrongNameHeader() {
	final RemoteServiceServletTestServiceAsync service = getAsyncService();
	((ServiceDefTarget) service)
			.setRpcRequestBuilder(new RpcRequestBuilder() {
				/**
				 * Copied from base class.
				 */
				@Override
				protected void doFinish(RequestBuilder rb) {
					// Don't set permutation strong name
					rb.setHeader(MODULE_BASE_HEADER, GWT.getModuleBaseURL());
				}

			});

	delayTestFinishForRpc();
	setTask(new AsyncTask<Void, Void, Void>() {

		@Override
		protected Void doInBackground(Void... arg0) {
			service.test(new AsyncCallback<Void>() {
				@Override
				public void onFailure(Throwable caught) {
					assertTrue(caught instanceof StatusCodeException);
					assertEquals(500,
							((StatusCodeException) caught).getStatusCode());
					finishTest();
				}

				@Override
				public void onSuccess(Void result) {
					fail();
				}
			});
			return null;
		}
	});
}
 
Example 38
Project: gwt-chronoscope   File: GssStyleElementGssContext.java   View source code 5 votes vote down vote up
protected void run() {
  if (!gssLoaded.contains(url)) {
    RequestBuilder rb = new RequestBuilder(RequestBuilder.GET, url);
    try {
      rb.sendRequest("", this);
    } catch (Exception e) {
      next();
    }
  } else {
    next();
  }
}
 
Example 39
Project: shortyz   File: Module.java   View source code 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 40
Project: shortyz   File: PuzzleServiceProxy.java   View source code 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);
    }
}