use of org.pentaho.mantle.client.solutionbrowser.fileproperties.PermissionsPanel in project pentaho-platform by pentaho.
the class SelectUserOrRoleDialog method fetchAllRoles.
public void fetchAllRoles(final ArrayList<String> existing, final Document fileInfo) {
try {
// $NON-NLS-1$
final String url = GWT.getHostPageBaseURL() + "api/userrolelist/permission-roles";
RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.GET, url);
// This header is required to force Internet Explorer to not cache values from the GET response.
requestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
requestBuilder.setHeader("accept", "application/json");
requestBuilder.sendRequest(null, new RequestCallback() {
public void onError(Request request, Throwable caught) {
MessageDialogBox dialogBox = new MessageDialogBox(Messages.getString("error"), Messages.getString("couldNotGetRoles"), false, false, // $NON-NLS-1$ //$NON-NLS-2$
true);
dialogBox.center();
}
public void onResponseReceived(Request request, Response response) {
JsArrayString roles = parseRolesJson(JsonUtils.escapeJsonForEval(response.getText()));
// filter out existing
rolesListBox.clear();
PermissionsPanel permPanel = new PermissionsPanel(null);
for (int i = 0; i < roles.length(); i++) {
String role = roles.get(i);
if (!existing.contains(role)) {
rolesListBox.addItem(role);
} else {
if (!permPanel.getNames(fileInfo, 1).contains(role) && permPanel.getNames(fileInfo, 0).contains(role)) {
// we have equal user/role pair(s) and user already in existing list
rolesListBox.addItem(role);
}
}
}
}
});
} catch (RequestException e) {
Window.alert(e.getMessage());
}
}
use of org.pentaho.mantle.client.solutionbrowser.fileproperties.PermissionsPanel in project pentaho-platform by pentaho.
the class SelectUserOrRoleDialog method fetchAllUsers.
public void fetchAllUsers(final ArrayList<String> existing, final Document fileInfo) {
try {
// $NON-NLS-1$
final String url = GWT.getHostPageBaseURL() + "api/userrolelist/permission-users";
RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.GET, url);
// This header is required to force Internet Explorer to not cache values from the GET response.
requestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
requestBuilder.setHeader("accept", "application/json");
requestBuilder.sendRequest(null, new RequestCallback() {
public void onError(Request request, Throwable caught) {
MessageDialogBox dialogBox = new MessageDialogBox(Messages.getString("error"), Messages.getString("couldNotGetUsers"), false, false, // $NON-NLS-1$ //$NON-NLS-2$
true);
dialogBox.center();
}
public void onResponseReceived(Request request, Response response) {
JsArrayString users = parseUsersJson(JsonUtils.escapeJsonForEval(response.getText()));
// filter out existing
usersListBox.clear();
PermissionsPanel permPanel = new PermissionsPanel(null);
for (int i = 0; i < users.length(); i++) {
String user = users.get(i);
if (!existing.contains(user)) {
usersListBox.addItem(user);
} else {
if (!permPanel.getNames(fileInfo, 0).contains(user) && permPanel.getNames(fileInfo, 1).contains(user)) {
// we have equal user/role pair(s) and role already in existing list
usersListBox.addItem(user);
}
}
}
}
});
} catch (RequestException e) {
Window.alert(e.getMessage());
}
}
Aggregations