Search in sources :

Example 21 with RequestBuilder

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());
    }
}
Also used : Response(com.google.gwt.http.client.Response) RequestBuilder(com.google.gwt.http.client.RequestBuilder) RequestCallback(com.google.gwt.http.client.RequestCallback) Timer(com.google.gwt.user.client.Timer) Request(com.google.gwt.http.client.Request) RequestException(com.google.gwt.http.client.RequestException)

Example 22 with RequestBuilder

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());
    }
}
Also used : Response(com.google.gwt.http.client.Response) RequestBuilder(com.google.gwt.http.client.RequestBuilder) RequestCallback(com.google.gwt.http.client.RequestCallback) Request(com.google.gwt.http.client.Request) RequestException(com.google.gwt.http.client.RequestException)

Example 23 with RequestBuilder

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);
    }
}
Also used : Response(com.google.gwt.http.client.Response) RequestBuilder(com.google.gwt.http.client.RequestBuilder) RequestCallback(com.google.gwt.http.client.RequestCallback) Request(com.google.gwt.http.client.Request) RequestException(com.google.gwt.http.client.RequestException)

Example 24 with RequestBuilder

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());
    }
}
Also used : Response(com.google.gwt.http.client.Response) RequestBuilder(com.google.gwt.http.client.RequestBuilder) RequestCallback(com.google.gwt.http.client.RequestCallback) Request(com.google.gwt.http.client.Request) RequestException(com.google.gwt.http.client.RequestException)

Example 25 with RequestBuilder

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());
    }
}
Also used : Response(com.google.gwt.http.client.Response) RequestBuilder(com.google.gwt.http.client.RequestBuilder) RequestCallback(com.google.gwt.http.client.RequestCallback) Request(com.google.gwt.http.client.Request) RequestException(com.google.gwt.http.client.RequestException) NativeEvent(com.google.gwt.dom.client.NativeEvent)

Aggregations

RequestBuilder (com.google.gwt.http.client.RequestBuilder)132 RequestException (com.google.gwt.http.client.RequestException)116 RequestCallback (com.google.gwt.http.client.RequestCallback)113 Response (com.google.gwt.http.client.Response)111 Request (com.google.gwt.http.client.Request)110 MessageDialogBox (org.pentaho.gwt.widgets.client.dialogs.MessageDialogBox)27 CsrfRequestBuilder (org.pentaho.mantle.client.csrf.CsrfRequestBuilder)22 JSONString (com.google.gwt.json.client.JSONString)19 ArrayList (java.util.ArrayList)16 Bindable (org.pentaho.ui.xul.stereotype.Bindable)15 IDatabaseConnection (org.pentaho.database.model.IDatabaseConnection)13 JSONObject (com.google.gwt.json.client.JSONObject)11 JsArrayString (com.google.gwt.core.client.JsArrayString)9 JSONArray (com.google.gwt.json.client.JSONArray)8 List (java.util.List)8 HTML (com.google.gwt.user.client.ui.HTML)7 IDialogCallback (org.pentaho.gwt.widgets.client.dialogs.IDialogCallback)7 EmptyRequestCallback (org.pentaho.mantle.client.EmptyRequestCallback)7 PromptDialogBox (org.pentaho.gwt.widgets.client.dialogs.PromptDialogBox)6 RepositoryFile (org.pentaho.gwt.widgets.client.filechooser.RepositoryFile)6