Search in sources :

Example 1 with CsrfRequestBuilder

use of org.pentaho.mantle.client.csrf.CsrfRequestBuilder in project pentaho-platform by pentaho.

the class ExecuteGlobalActionsCommand method performOperation.

protected void performOperation() {
    // $NON-NLS-1$
    final String url = GWT.getHostPageBaseURL() + "api/system/refresh/globalActions";
    RequestBuilder requestBuilder = new CsrfRequestBuilder(RequestBuilder.GET, url);
    requestBuilder.setHeader("accept", "text/plain");
    requestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
    try {
        requestBuilder.sendRequest(null, new RequestCallback() {

            public void onError(Request request, Throwable exception) {
            // showError(exception);
            }

            public void onResponseReceived(Request request, Response response) {
                MessageDialogBox dialogBox = new MessageDialogBox(Messages.getString("info"), Messages.getString("globalActionsExecutedSuccessfully"), false, false, // $NON-NLS-1$ //$NON-NLS-2$
                true);
                dialogBox.center();
            }
        });
    } catch (RequestException e) {
        Window.alert(e.getMessage());
    // showError(e);
    }
}
Also used : Response(com.google.gwt.http.client.Response) RequestBuilder(com.google.gwt.http.client.RequestBuilder) CsrfRequestBuilder(org.pentaho.mantle.client.csrf.CsrfRequestBuilder) RequestCallback(com.google.gwt.http.client.RequestCallback) MessageDialogBox(org.pentaho.gwt.widgets.client.dialogs.MessageDialogBox) CsrfRequestBuilder(org.pentaho.mantle.client.csrf.CsrfRequestBuilder) Request(com.google.gwt.http.client.Request) RequestException(com.google.gwt.http.client.RequestException)

Example 2 with CsrfRequestBuilder

use of org.pentaho.mantle.client.csrf.CsrfRequestBuilder in project pentaho-platform by pentaho.

the class AbstractFilePickList method save.

/**
 * Convert the FilePickList to JSON and save it to a user setting
 *
 * @param settingName
 */
public void save(String settingName) {
    String url = GWT.getHostPageBaseURL() + "api/user-settings/" + settingName;
    RequestBuilder builder = new CsrfRequestBuilder(RequestBuilder.POST, url);
    try {
        builder.setHeader("accept", "application/json");
        builder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
        builder.sendRequest(toJson().toString(), new RequestCallback() {

            public void onError(Request request, Throwable exception) {
                MessageDialogBox dialog = new MessageDialogBox(Messages.getString("error"), Messages.getString("couldNotSetUserSettings"), true, false, true);
                dialog.center();
            }

            public void onResponseReceived(Request request, Response response) {
                fireOnSavedEvent();
            }
        });
    } catch (RequestException e) {
    // showError(e);
    }
}
Also used : Response(com.google.gwt.http.client.Response) CsrfRequestBuilder(org.pentaho.mantle.client.csrf.CsrfRequestBuilder) RequestBuilder(com.google.gwt.http.client.RequestBuilder) RequestCallback(com.google.gwt.http.client.RequestCallback) MessageDialogBox(org.pentaho.gwt.widgets.client.dialogs.MessageDialogBox) CsrfRequestBuilder(org.pentaho.mantle.client.csrf.CsrfRequestBuilder) Request(com.google.gwt.http.client.Request) RequestException(com.google.gwt.http.client.RequestException)

Example 3 with CsrfRequestBuilder

use of org.pentaho.mantle.client.csrf.CsrfRequestBuilder in project pentaho-platform by pentaho.

the class RefreshSystemSettingsCommand method performOperation.

protected void performOperation() {
    // $NON-NLS-1$
    final String url = GWT.getHostPageBaseURL() + "api/system/refresh/systemSettings";
    RequestBuilder requestBuilder = new CsrfRequestBuilder(RequestBuilder.GET, url);
    requestBuilder.setHeader("accept", "text/plain");
    requestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
    try {
        requestBuilder.sendRequest(null, new RequestCallback() {

            public void onError(Request request, Throwable exception) {
            // showError(exception);
            }

            public void onResponseReceived(Request request, Response response) {
                MessageDialogBox dialogBox = new MessageDialogBox(Messages.getString("info"), Messages.getString("refreshSystemSettingsSuccess"), false, false, // $NON-NLS-1$ //$NON-NLS-2$
                true);
                dialogBox.center();
            }
        });
    } catch (RequestException e) {
        Window.alert(e.getMessage());
    // showError(e);
    }
}
Also used : Response(com.google.gwt.http.client.Response) RequestBuilder(com.google.gwt.http.client.RequestBuilder) CsrfRequestBuilder(org.pentaho.mantle.client.csrf.CsrfRequestBuilder) RequestCallback(com.google.gwt.http.client.RequestCallback) MessageDialogBox(org.pentaho.gwt.widgets.client.dialogs.MessageDialogBox) CsrfRequestBuilder(org.pentaho.mantle.client.csrf.CsrfRequestBuilder) Request(com.google.gwt.http.client.Request) RequestException(com.google.gwt.http.client.RequestException)

Example 4 with CsrfRequestBuilder

use of org.pentaho.mantle.client.csrf.CsrfRequestBuilder in project pentaho-platform by pentaho.

the class ShowBrowserCommand method execute.

public void execute() {
    final SolutionBrowserPanel solutionBrowserPerspective = SolutionBrowserPanel.getInstance();
    solutionBrowserPerspective.setNavigatorShowing(state);
    if (PerspectiveManager.getInstance().getActivePerspective().getId().equalsIgnoreCase(PerspectiveManager.OPENED_PERSPECTIVE)) {
        PerspectiveManager.getInstance().setPerspective(PerspectiveManager.OPENED_PERSPECTIVE);
    }
    String url = GWT.getHostPageBaseURL() + "api/user-settings/MANTLE_SHOW_NAVIGATOR";
    RequestBuilder builder = new CsrfRequestBuilder(RequestBuilder.POST, url);
    try {
        builder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
        builder.sendRequest("" + state, EmptyRequestCallback.getInstance());
    } catch (RequestException e) {
    // showError(e);
    }
}
Also used : RequestBuilder(com.google.gwt.http.client.RequestBuilder) CsrfRequestBuilder(org.pentaho.mantle.client.csrf.CsrfRequestBuilder) CsrfRequestBuilder(org.pentaho.mantle.client.csrf.CsrfRequestBuilder) RequestException(com.google.gwt.http.client.RequestException) SolutionBrowserPanel(org.pentaho.mantle.client.solutionbrowser.SolutionBrowserPanel)

Example 5 with CsrfRequestBuilder

use of org.pentaho.mantle.client.csrf.CsrfRequestBuilder in project pentaho-platform by pentaho.

the class SwitchThemeCommand method performOperation.

protected void performOperation(boolean feedback) {
    final HTML messageTextBox = new HTML(Messages.getString("confirmSwitchTheme.message"));
    final PromptDialogBox fileMoveToTrashWarningDialogBox = new PromptDialogBox(Messages.getString("confirmSwitchTheme.title"), Messages.getString("confirmSwitchTheme.ok"), Messages.getString("confirmSwitchTheme.cancel"), true, true);
    fileMoveToTrashWarningDialogBox.setContent(messageTextBox);
    final IDialogCallback callback = new IDialogCallback() {

        public void cancelPressed() {
        }

        public void okPressed() {
            // $NON-NLS-1$
            final String url = GWT.getHostPageBaseURL() + "api/theme/set";
            RequestBuilder setThemeRequestBuilder = new CsrfRequestBuilder(RequestBuilder.POST, url);
            setThemeRequestBuilder.setHeader("accept", "text/plain");
            setThemeRequestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
            try {
                setThemeRequestBuilder.sendRequest(theme, new RequestCallback() {

                    public void onError(Request request, Throwable exception) {
                    // showError(exception);
                    }

                    public void onResponseReceived(Request request, Response response) {
                        // forcing a setTimeout to fix a problem in IE BISERVER-6385
                        Scheduler.get().scheduleDeferred(new Command() {

                            public void execute() {
                                Window.Location.reload();
                            }
                        });
                    }
                });
            } catch (RequestException e) {
                Window.alert(e.getMessage());
            // showError(e);
            }
        }
    };
    fileMoveToTrashWarningDialogBox.setCallback(callback);
    fileMoveToTrashWarningDialogBox.center();
}
Also used : Response(com.google.gwt.http.client.Response) CsrfRequestBuilder(org.pentaho.mantle.client.csrf.CsrfRequestBuilder) RequestBuilder(com.google.gwt.http.client.RequestBuilder) RequestCallback(com.google.gwt.http.client.RequestCallback) PromptDialogBox(org.pentaho.gwt.widgets.client.dialogs.PromptDialogBox) Command(com.google.gwt.user.client.Command) CsrfRequestBuilder(org.pentaho.mantle.client.csrf.CsrfRequestBuilder) Request(com.google.gwt.http.client.Request) HTML(com.google.gwt.user.client.ui.HTML) IDialogCallback(org.pentaho.gwt.widgets.client.dialogs.IDialogCallback) RequestException(com.google.gwt.http.client.RequestException)

Aggregations

RequestBuilder (com.google.gwt.http.client.RequestBuilder)10 RequestException (com.google.gwt.http.client.RequestException)10 CsrfRequestBuilder (org.pentaho.mantle.client.csrf.CsrfRequestBuilder)10 Request (com.google.gwt.http.client.Request)7 RequestCallback (com.google.gwt.http.client.RequestCallback)7 Response (com.google.gwt.http.client.Response)7 MessageDialogBox (org.pentaho.gwt.widgets.client.dialogs.MessageDialogBox)6 SolutionBrowserPanel (org.pentaho.mantle.client.solutionbrowser.SolutionBrowserPanel)2 JSONString (com.google.gwt.json.client.JSONString)1 Command (com.google.gwt.user.client.Command)1 HTML (com.google.gwt.user.client.ui.HTML)1 IDialogCallback (org.pentaho.gwt.widgets.client.dialogs.IDialogCallback)1 PromptDialogBox (org.pentaho.gwt.widgets.client.dialogs.PromptDialogBox)1 GenericEvent (org.pentaho.mantle.client.events.GenericEvent)1