Search in sources :

Example 31 with Response

use of com.google.gwt.http.client.Response 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 32 with Response

use of com.google.gwt.http.client.Response 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());
    }
}
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 33 with Response

use of com.google.gwt.http.client.Response 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());
    }
}
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 34 with Response

use of com.google.gwt.http.client.Response 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());
    }
}
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 35 with Response

use of com.google.gwt.http.client.Response 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)

Aggregations

Response (com.google.gwt.http.client.Response)167 Request (com.google.gwt.http.client.Request)165 RequestCallback (com.google.gwt.http.client.RequestCallback)165 RequestException (com.google.gwt.http.client.RequestException)158 RequestBuilder (com.google.gwt.http.client.RequestBuilder)108 JSONException (com.google.gwt.json.client.JSONException)55 HttpException (com.willshex.gson.web.service.client.HttpException)55 MessageDialogBox (org.pentaho.gwt.widgets.client.dialogs.MessageDialogBox)17 BlockUsersRequest (com.willshex.blogwt.shared.api.user.call.BlockUsersRequest)12 BlockUsersResponse (com.willshex.blogwt.shared.api.user.call.BlockUsersResponse)12 ChangePasswordRequest (com.willshex.blogwt.shared.api.user.call.ChangePasswordRequest)12 ChangePasswordResponse (com.willshex.blogwt.shared.api.user.call.ChangePasswordResponse)12 ChangeUserAccessRequest (com.willshex.blogwt.shared.api.user.call.ChangeUserAccessRequest)12 ChangeUserAccessResponse (com.willshex.blogwt.shared.api.user.call.ChangeUserAccessResponse)12 ChangeUserDetailsRequest (com.willshex.blogwt.shared.api.user.call.ChangeUserDetailsRequest)12 ChangeUserDetailsResponse (com.willshex.blogwt.shared.api.user.call.ChangeUserDetailsResponse)12 CheckUsernameRequest (com.willshex.blogwt.shared.api.user.call.CheckUsernameRequest)12 CheckUsernameResponse (com.willshex.blogwt.shared.api.user.call.CheckUsernameResponse)12 FollowUsersRequest (com.willshex.blogwt.shared.api.user.call.FollowUsersRequest)12 FollowUsersResponse (com.willshex.blogwt.shared.api.user.call.FollowUsersResponse)12