use of com.google.gwt.http.client.RequestBuilder in project gerrit by GerritCodeReview.
the class RestApi method request.
private RequestBuilder request(Method method) {
RequestBuilder req = new RequestBuilder(method, url());
if (ifNoneMatch != null) {
req.setHeader("If-None-Match", ifNoneMatch);
}
req.setHeader("Accept", JSON_TYPE);
if (Gerrit.getXGerritAuth() != null) {
req.setHeader(HostPageData.XSRF_HEADER_NAME, Gerrit.getXGerritAuth());
}
return req;
}
use of com.google.gwt.http.client.RequestBuilder in project gerrit by GerritCodeReview.
the class Gerrit method getDocIndex.
private static void getDocIndex(final AsyncCallback<DocInfo> cb) {
RequestBuilder req = new RequestBuilder(RequestBuilder.HEAD, GWT.getHostPageBaseURL() + INDEX);
req.setCallback(new RequestCallback() {
@Override
public void onResponseReceived(Request req, Response resp) {
switch(resp.getStatusCode()) {
case Response.SC_OK:
case Response.SC_MOVED_PERMANENTLY:
case Response.SC_MOVED_TEMPORARILY:
cb.onSuccess(DocInfo.create());
break;
default:
cb.onSuccess(null);
break;
}
}
@Override
public void onError(Request request, Throwable e) {
cb.onFailure(e);
}
});
try {
req.send();
} catch (RequestException e) {
cb.onFailure(e);
}
}
use of com.google.gwt.http.client.RequestBuilder in project opennms by OpenNMS.
the class Navigation method linkTopOpenNMSClicked.
@UiHandler("m_link")
public void linkTopOpenNMSClicked(ClickEvent event) {
StringBuffer postData = new StringBuffer();
// note param pairs are separated by a '&'
// and each key-value pair is separated by a '='
postData.append(URL.encode("j_username")).append("=").append(URL.encode("ipv6"));
postData.append("&");
postData.append(URL.encode("j_password")).append("=").append(URL.encode("ipv6"));
postData.append("&");
postData.append(URL.encode("Login")).append("=").append(URL.encode("login"));
RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode("/opennms/j_spring_security_check"));
builder.setHeader("Content-type", "application/x-www-form-urlencoded");
try {
builder.sendRequest(postData.toString(), new RequestCallback() {
@Override
public void onResponseReceived(Request request, Response response) {
if (response.getStatusCode() == 200) {
Window.open("/opennms/index.jsp", "_target", null);
} else {
Window.alert("Failed to login");
}
}
@Override
public void onError(Request request, Throwable exception) {
Window.alert("Problem Logging in");
}
});
} catch (RequestException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// Window.alert("Cliking link to OpenNMS");
}
use of com.google.gwt.http.client.RequestBuilder in project pentaho-platform by pentaho.
the class UserRolesAdminPanelController method initializeActionBaseSecurityElements.
private void initializeActionBaseSecurityElements() {
final String url = GWT.getHostPageBaseURL() + "api/userroledao/logicalRoleMap";
RequestBuilder executableTypesRequestBuilder = new RequestBuilder(RequestBuilder.GET, url);
executableTypesRequestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
executableTypesRequestBuilder.setHeader("accept", "application/json");
try {
executableTypesRequestBuilder.sendRequest(null, new RequestCallback() {
public void onError(Request request, Throwable exception) {
}
public void onResponseReceived(Request request, Response response) {
String roleMappings = response.getText();
rolesPermissionsPanel.initializeActionBaseSecurityElements(roleMappings);
systemRolesPermissionsPanel.initializeActionBaseSecurityElements(roleMappings);
}
});
} catch (RequestException e) {
// ignored
}
}
use of com.google.gwt.http.client.RequestBuilder in project pentaho-platform by pentaho.
the class UserRolesAdminPanelController method getUsersInRole.
private void getUsersInRole(String role) {
final String url = GWT.getHostPageBaseURL() + "api/userroledao/roleMembers?roleName=" + encodeUri(role);
RequestBuilder executableTypesRequestBuilder = new RequestBuilder(RequestBuilder.GET, url);
executableTypesRequestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
executableTypesRequestBuilder.setHeader("accept", "application/xml");
try {
executableTypesRequestBuilder.sendRequest(null, new RequestCallback() {
public void onError(Request request, Throwable exception) {
displayErrorInMessageBox(Messages.getString("Error"), exception.getLocalizedMessage());
}
public void onResponseReceived(Request request, Response response) {
selectedMembersListBox.clear();
for (String user : getSortedItems("users", response)) {
selectedMembersListBox.addItem(user);
}
updateHelperDiv(HorizontalScrollWrapper.getListBoxWrapperUIId(selectedMembersListBox));
Timer t = new Timer() {
public void run() {
if (usersListBox.getItemCount() > 0) {
cancel();
// availableMembersListBox = usersListBox - selectedMembersListBox
availableMembersListBox.clear();
for (int i = 0; i < usersListBox.getItemCount(); i++) {
String user = usersListBox.getValue(i);
boolean isSelected = false;
for (int j = 0; j < selectedMembersListBox.getItemCount(); j++) {
if (selectedMembersListBox.getValue(j).equals(user)) {
isSelected = true;
}
}
if (!isSelected) {
availableMembersListBox.addItem(user);
}
}
updateHelperDiv(HorizontalScrollWrapper.getListBoxWrapperUIId(availableMembersListBox));
}
}
};
t.scheduleRepeating(100);
}
});
} catch (RequestException e) {
displayErrorInMessageBox(Messages.getString("Error"), e.getLocalizedMessage());
}
}
Aggregations