Search in sources :

Example 46 with RequestCallback

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);
    }
}
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 47 with RequestCallback

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());
    }
}
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 48 with RequestCallback

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());
    }
}
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)

Example 49 with RequestCallback

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());
    }
}
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 50 with RequestCallback

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
    }
}
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

RequestCallback (com.google.gwt.http.client.RequestCallback)175 Response (com.google.gwt.http.client.Response)170 Request (com.google.gwt.http.client.Request)169 RequestException (com.google.gwt.http.client.RequestException)162 RequestBuilder (com.google.gwt.http.client.RequestBuilder)113 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)16 CsrfRequestBuilder (org.pentaho.mantle.client.csrf.CsrfRequestBuilder)14 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