use of com.google.gwt.http.client.RequestException 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.RequestException 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.RequestException 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.RequestException 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());
}
}
use of com.google.gwt.http.client.RequestException in project pentaho-platform by pentaho.
the class UserRolesAdminPanelController method saveUser.
public void saveUser(final String name, final String password) {
String serviceUrl = GWT.getHostPageBaseURL() + "api/userroledao/createUser";
RequestBuilder executableTypesRequestBuilder = new RequestBuilder(RequestBuilder.PUT, serviceUrl);
try {
executableTypesRequestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
executableTypesRequestBuilder.setHeader("Content-Type", "application/json");
String json = "{\"userName\": \"" + encodeUri(name) + "\", \"password\": \"" + encodeUri(password) + "\"}";
executableTypesRequestBuilder.sendRequest(json, new RequestCallback() {
public void onError(Request request, Throwable exception) {
displayErrorInMessageBox(Messages.getString("Error"), exception.getLocalizedMessage());
}
public void onResponseReceived(Request request, Response response) {
initializeAvailableUsers(name);
initializeRoles(rolesListBox.getValue(rolesListBox.getSelectedIndex()), "api/userroledao/roles", rolesListBox);
}
});
} catch (RequestException e) {
displayErrorInMessageBox(Messages.getString("Error"), e.getLocalizedMessage());
}
}
Aggregations