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());
}
}
use of com.google.gwt.http.client.RequestBuilder in project pentaho-platform by pentaho.
the class UserRolesAdminPanelController method deleteUsers.
public void deleteUsers() {
StringBuilder selectedUsers = new StringBuilder();
for (int i = 0; i < usersListBox.getItemCount(); i++) {
if (usersListBox.isItemSelected(i)) {
selectedUsers.append(encodeUri(usersListBox.getValue(i) + delimiter));
}
}
String serviceUrl = GWT.getHostPageBaseURL() + "api/userroledao/deleteUsers?userNames=" + selectedUsers.toString();
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);
userPasswordTextBox.setText("");
availableRolesListBox.clear();
selectedRolesListBox.clear();
updateHelperDiv(HorizontalScrollWrapper.getListBoxWrapperUIId(availableMembersListBox));
updateHelperDiv(HorizontalScrollWrapper.getListBoxWrapperUIId(selectedMembersListBox));
editPasswordButton.setEnabled(false);
initializeAvailableUsers(null);
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.RequestBuilder 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);
}
}
use of com.google.gwt.http.client.RequestBuilder in project pentaho-platform by pentaho.
the class UserRolesAdminPanelController method modifyRoleUsers.
private void modifyRoleUsers(final String roleName, 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);
getUsersInRole(roleName);
initializeAvailableUsers(usersListBox.getValue(usersListBox.getSelectedIndex()));
}
});
} catch (RequestException e) {
displayErrorInMessageBox(Messages.getString("Error"), e.getLocalizedMessage());
}
}
use of com.google.gwt.http.client.RequestBuilder in project pentaho-platform by pentaho.
the class UserRolesAdminPanelController method initializeList.
private void initializeList(final String type, final String defaultValue, String serviceUrl, final ListBox listBox) {
final String url = GWT.getHostPageBaseURL() + serviceUrl;
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) {
listBox.clear();
NativeEvent event = com.google.gwt.dom.client.Document.get().createChangeEvent();
for (String role : getSortedItems(type, response)) {
listBox.addItem(role);
if (!StringUtils.isEmpty(defaultValue)) {
if (role.equals(defaultValue)) {
listBox.setSelectedIndex(listBox.getItemCount() - 1);
DomEvent.fireNativeEvent(event, listBox);
}
}
}
if (listBox.getSelectedIndex() == -1 && listBox.getItemCount() > 0) {
listBox.setSelectedIndex(0);
DomEvent.fireNativeEvent(event, listBox);
}
updateHelperDiv(HorizontalScrollWrapper.getListBoxWrapperUIId(listBox));
}
});
} catch (RequestException e) {
displayErrorInMessageBox(Messages.getString("Error"), e.getLocalizedMessage());
}
}
Aggregations