use of com.google.gwt.http.client.RequestCallback 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.RequestCallback 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());
}
}
use of com.google.gwt.http.client.RequestCallback in project pentaho-platform by pentaho.
the class UserRolesAdminPanelController method getRolesForUser.
private void getRolesForUser(String user) {
final String url = GWT.getHostPageBaseURL() + "api/userroledao/userRoles?userName=" + encodeUri(user);
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) {
selectedRolesListBox.clear();
for (String role : getSortedItems("roles", response)) {
selectedRolesListBox.addItem(role);
}
updateHelperDiv(HorizontalScrollWrapper.getListBoxWrapperUIId(selectedRolesListBox));
Timer t = new Timer() {
public void run() {
if (rolesListBox.getItemCount() > 0) {
cancel();
// availableRolesListBox = rolesListBox - selectedRolesListBox
availableRolesListBox.clear();
for (int i = 0; i < rolesListBox.getItemCount(); i++) {
String role = rolesListBox.getValue(i);
boolean isSelected = false;
for (int j = 0; j < selectedRolesListBox.getItemCount(); j++) {
if (selectedRolesListBox.getValue(j).equals(role)) {
isSelected = true;
}
}
if (!isSelected) {
availableRolesListBox.addItem(role);
}
}
updateHelperDiv(HorizontalScrollWrapper.getListBoxWrapperUIId(availableRolesListBox));
}
}
};
t.scheduleRepeating(100);
}
});
} catch (RequestException e) {
displayErrorInMessageBox(Messages.getString("Error"), e.getLocalizedMessage());
}
}
use of com.google.gwt.http.client.RequestCallback in project pentaho-platform by pentaho.
the class UserRolesAdminPanelController method modifyUserRoles.
private void modifyUserRoles(final String userName, String serviceUrl) {
RequestBuilder executableTypesRequestBuilder = new RequestBuilder(RequestBuilder.PUT, serviceUrl);
try {
executableTypesRequestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
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) {
checkForError(Messages.getString("Error"), response);
getRolesForUser(userName);
initializeRoles(rolesListBox.getValue(rolesListBox.getSelectedIndex()), "api/userroledao/roles", rolesListBox);
}
});
} catch (RequestException e) {
displayErrorInMessageBox(Messages.getString("Error"), e.getLocalizedMessage());
}
}
use of com.google.gwt.http.client.RequestCallback in project pentaho-platform by pentaho.
the class UserRolesAdminPanelController method processLDAPOrJDBCmode.
private void processLDAPOrJDBCmode() {
final String url = GWT.getHostPageBaseURL() + "api/system/authentication-provider";
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 resText = response.getText();
usingPentahoSecurity = resText.contains("\"jackrabbit\"") || resText.contains("\"super\"");
userRolePermissions(usingPentahoSecurity);
}
});
} catch (RequestException e) {
userRolePermissions(false);
}
}
Aggregations