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);
}
}
use of com.google.gwt.http.client.RequestCallback 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.RequestCallback 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());
}
}
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\": \"ENC:" + b64encode(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) {
if (response.getStatusCode() != Response.SC_NO_CONTENT) {
String errorMsg = Messages.getString("newUserErrorMessage");
String errorValidationMessage = response.getHeader(PUC_VALIDATION_ERROR_MESSAGE);
if (errorValidationMessage != null) {
errorMsg = errorMsg + "\n" + errorValidationMessage;
}
showXulErrorMessage(Messages.getString("newUser"), errorMsg);
} else {
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 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
}
}
Aggregations