Search in sources :

Example 96 with Response

use of com.google.gwt.http.client.Response in project pentaho-platform by pentaho.

the class UserRolesAdminPanelController method updatePassword.

public void updatePassword(String newPassword, String administratorPassword, final ServiceCallback callback) {
    String userName = usersListBox.getValue(usersListBox.getSelectedIndex());
    String serviceUrl = GWT.getHostPageBaseURL() + "api/userroledao/updatePassword";
    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(userName) + "\", \"password\": \"" + encodeUri(newPassword) + "\", \"administratorPassword\": \"" + encodeUri(administratorPassword) + "\"}";
        executableTypesRequestBuilder.sendRequest(json, new RequestCallback() {

            public void onError(Request request, Throwable exception) {
                showXulErrorMessage(Messages.getString("changePasswordErrorTitle"), Messages.getString("changePasswordErrorMessage"));
                callback.serviceResult(false);
            }

            public void onResponseReceived(Request request, Response response) {
                if (response.getStatusCode() != Response.SC_OK) {
                    showXulErrorMessage(Messages.getString("changePasswordErrorTitle"), Messages.getString("changePasswordErrorMessage"));
                    callback.serviceResult(false);
                } else {
                    callback.serviceResult(true);
                }
            }
        });
    } catch (RequestException e) {
        showXulErrorMessage(Messages.getString("changePasswordErrorTitle"), Messages.getString("changePasswordErrorMessage"));
        callback.serviceResult(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 97 with Response

use of com.google.gwt.http.client.Response in project pentaho-platform by pentaho.

the class AbstractFilePropertiesCommand method performOperation.

public void performOperation() {
    final SolutionFileActionEvent event = new SolutionFileActionEvent();
    event.setAction(this.getClass().getName());
    if (getRepositoryFile() != null) {
        final RepositoryFile item = getRepositoryFile();
        // Checking if the user has access to manage permissions
        String url = contextURL + "api/repo/files/" + SolutionBrowserPanel.pathToId(item.getPath()) + "/canAccess?permissions=" + // $NON-NLS-1$ //$NON-NLS-2$
        MANAGE_ACLS;
        RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, url);
        try {
            builder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
            builder.sendRequest(null, new RequestCallback() {

                public void onError(Request request, Throwable exception) {
                    FilePropertiesDialog dialog = new FilePropertiesDialog(item, new PentahoTabPanel(), null, getActiveTab(), false);
                    dialog.showTab(getActiveTab());
                    dialog.center();
                    event.setMessage(exception.getMessage());
                    EventBusUtil.EVENT_BUS.fireEvent(event);
                }

                public void onResponseReceived(Request request, Response response) {
                    FilePropertiesDialog dialog = new FilePropertiesDialog(item, new PentahoTabPanel(), null, getActiveTab(), Boolean.parseBoolean(response.getText()));
                    dialog.showTab(getActiveTab());
                    dialog.center();
                    event.setMessage("Success");
                    EventBusUtil.EVENT_BUS.fireEvent(event);
                }
            });
        } catch (RequestException e) {
            FilePropertiesDialog dialog = new FilePropertiesDialog(item, new PentahoTabPanel(), null, getActiveTab(), false);
            dialog.showTab(getActiveTab());
            dialog.center();
            event.setMessage(e.getMessage());
            EventBusUtil.EVENT_BUS.fireEvent(event);
        }
    }
}
Also used : Response(com.google.gwt.http.client.Response) RequestBuilder(com.google.gwt.http.client.RequestBuilder) RequestCallback(com.google.gwt.http.client.RequestCallback) FilePropertiesDialog(org.pentaho.mantle.client.solutionbrowser.fileproperties.FilePropertiesDialog) Request(com.google.gwt.http.client.Request) RepositoryFile(org.pentaho.gwt.widgets.client.filechooser.RepositoryFile) PentahoTabPanel(org.pentaho.gwt.widgets.client.tabs.PentahoTabPanel) SolutionFileActionEvent(org.pentaho.mantle.client.events.SolutionFileActionEvent) RequestException(com.google.gwt.http.client.RequestException)

Example 98 with Response

use of com.google.gwt.http.client.Response in project pentaho-platform by pentaho.

the class DeleteFolderCommand method performOperation.

protected void performOperation(boolean feedback) {
    final SolutionFolderActionEvent event = new SolutionFolderActionEvent();
    event.setAction(this.getClass().getName());
    final String filesList = repositoryFile.getId();
    final String folderName = repositoryFile.getTitle() == null ? repositoryFile.getName() : repositoryFile.getTitle();
    final HTML messageTextBox = new HTML(Messages.getString("moveToTrashQuestionFolder", escapeHtmlEntities(folderName)));
    final PromptDialogBox folderDeleteWarningDialogBox = new PromptDialogBox(Messages.getString("moveToTrash"), Messages.getString("yesMoveToTrash"), Messages.getString("no"), true, true);
    folderDeleteWarningDialogBox.setContent(messageTextBox);
    final IDialogCallback callback = new IDialogCallback() {

        public void cancelPressed() {
            folderDeleteWarningDialogBox.hide();
        }

        public void okPressed() {
            // $NON-NLS-1$
            String deleteFilesURL = contextURL + "api/repo/files/delete";
            RequestBuilder deleteFilesRequestBuilder = new RequestBuilder(RequestBuilder.PUT, deleteFilesURL);
            deleteFilesRequestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
            // $NON-NLS-1$//$NON-NLS-2$
            deleteFilesRequestBuilder.setHeader("Content-Type", "text/plain");
            try {
                deleteFilesRequestBuilder.sendRequest(filesList, new RequestCallback() {

                    @Override
                    public void onError(Request request, Throwable exception) {
                        MessageDialogBox dialogBox = new // $NON-NLS-1$ //$NON-NLS-2$
                        MessageDialogBox(// $NON-NLS-1$ //$NON-NLS-2$
                        Messages.getString("error"), // $NON-NLS-1$ //$NON-NLS-2$
                        Messages.getString("couldNotDeleteFolder"), false, false, true);
                        dialogBox.center();
                        event.setMessage(Messages.getString("couldNotDeleteFolder"));
                        EventBusUtil.EVENT_BUS.fireEvent(event);
                    }

                    @Override
                    public void onResponseReceived(Request request, Response response) {
                        if (response.getStatusCode() == 200) {
                            new RefreshRepositoryCommand().execute(false);
                            event.setMessage("Success");
                            FileChooserDialog.setIsDirty(Boolean.TRUE);
                            setBrowseRepoDirty(Boolean.TRUE);
                            EventBusUtil.EVENT_BUS.fireEvent(event);
                        } else {
                            MessageDialogBox dialogBox = new // $NON-NLS-1$ //$NON-NLS-2$
                            MessageDialogBox(// $NON-NLS-1$ //$NON-NLS-2$
                            Messages.getString("error"), // $NON-NLS-1$ //$NON-NLS-2$
                            Messages.getString("couldNotDeleteFolder"), false, false, true);
                            dialogBox.center();
                            event.setMessage(Messages.getString("couldNotDeleteFolder"));
                            EventBusUtil.EVENT_BUS.fireEvent(event);
                        }
                    }
                });
            } catch (RequestException e) {
                MessageDialogBox dialogBox = new // $NON-NLS-1$ //$NON-NLS-2$
                MessageDialogBox(// $NON-NLS-1$ //$NON-NLS-2$
                Messages.getString("error"), // $NON-NLS-1$ //$NON-NLS-2$
                Messages.getString("couldNotDeleteFolder"), false, false, true);
                dialogBox.center();
                event.setMessage(Messages.getString("couldNotDeleteFolder"));
                EventBusUtil.EVENT_BUS.fireEvent(event);
            }
        }
    };
    folderDeleteWarningDialogBox.setCallback(callback);
    folderDeleteWarningDialogBox.center();
}
Also used : RequestBuilder(com.google.gwt.http.client.RequestBuilder) MessageDialogBox(org.pentaho.gwt.widgets.client.dialogs.MessageDialogBox) PromptDialogBox(org.pentaho.gwt.widgets.client.dialogs.PromptDialogBox) SolutionFolderActionEvent(org.pentaho.mantle.client.events.SolutionFolderActionEvent) 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) Response(com.google.gwt.http.client.Response) RequestCallback(com.google.gwt.http.client.RequestCallback)

Example 99 with Response

use of com.google.gwt.http.client.Response in project pentaho-platform by pentaho.

the class DeletePermanentFileCommand method performOperation.

/*
 * (non-Javadoc)
 *
 * @see com.google.gwt.user.client.Command#execute()
 */
protected void performOperation(boolean feedback) {
    final SolutionFileActionEvent event = new SolutionFileActionEvent();
    event.setAction(this.getClass().getName());
    VerticalPanel vp = new VerticalPanel();
    String deleteMessage;
    final PromptDialogBox deleteConfirmDialog;
    if (mode.equals("purge")) {
        deleteMessage = Messages.getString("deleteAllQuestion");
        deleteConfirmDialog = new PromptDialogBox(Messages.getString("emptyTrash"), Messages.getString("yesEmptyTrash"), Messages.getString("no"), false, true, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        vp);
    } else {
        if (MULTIPLE_DELETE_TYPE.equals(type)) {
            deleteMessage = Messages.getString("deleteMultiQuestion");
        } else {
            deleteMessage = Messages.getString("deleteQuestion", type);
        }
        deleteConfirmDialog = new PromptDialogBox(Messages.getString("permDelete"), Messages.getString("yesPermDelete"), Messages.getString("no"), false, true, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        vp);
    }
    // $NON-NLS-1$
    vp.add(new HTML(deleteMessage));
    final IDialogCallback callback = new IDialogCallback() {

        public void cancelPressed() {
            deleteConfirmDialog.hide();
        }

        public void okPressed() {
            String temp = "";
            // Add js file list
            temp = temp + fileList;
            // remove trailing ","
            temp = temp.substring(0, temp.length() - 1);
            final String filesList = temp;
            // $NON-NLS-1$
            String deleteFilesURL = contextURL + "api/repo/files/deletepermanent";
            RequestBuilder deleteFilesRequestBuilder = new RequestBuilder(RequestBuilder.PUT, deleteFilesURL);
            // $NON-NLS-1$//$NON-NLS-2$
            deleteFilesRequestBuilder.setHeader("Content-Type", "text/plain");
            deleteFilesRequestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
            try {
                deleteFilesRequestBuilder.sendRequest(filesList, new RequestCallback() {

                    @Override
                    public void onError(Request request, Throwable exception) {
                        MessageDialogBox dialogBox = new // $NON-NLS-1$ //$NON-NLS-2$
                        MessageDialogBox(// $NON-NLS-1$ //$NON-NLS-2$
                        Messages.getString("error"), // $NON-NLS-1$ //$NON-NLS-2$
                        Messages.getString("couldNotDeleteFile"), false, false, true);
                        dialogBox.center();
                        event.setMessage(Messages.getString("couldNotDeleteFile"));
                        EventBusUtil.EVENT_BUS.fireEvent(event);
                    }

                    @Override
                    public void onResponseReceived(Request request, Response response) {
                        if (response.getStatusCode() == 200) {
                            new RefreshRepositoryCommand().execute(false);
                            event.setMessage("Success");
                            FileChooserDialog.setIsDirty(Boolean.TRUE);
                            setBrowseRepoDirty(Boolean.TRUE);
                            EventBusUtil.EVENT_BUS.fireEvent(event);
                        } else {
                            event.setMessage(Messages.getString("couldNotDeleteFile"));
                            EventBusUtil.EVENT_BUS.fireEvent(event);
                        }
                    }
                });
            } catch (RequestException e) {
                MessageDialogBox dialogBox = new // $NON-NLS-1$ //$NON-NLS-2$
                MessageDialogBox(// $NON-NLS-1$ //$NON-NLS-2$
                Messages.getString("error"), // $NON-NLS-1$ //$NON-NLS-2$
                Messages.getString("couldNotDeleteFile"), false, false, true);
                dialogBox.center();
                event.setMessage(Messages.getString("couldNotDeleteFile"));
                EventBusUtil.EVENT_BUS.fireEvent(event);
            }
        }
    };
    if (!feedback) {
        callback.okPressed();
    } else {
        deleteConfirmDialog.setCallback(callback);
        deleteConfirmDialog.center();
    }
}
Also used : RequestBuilder(com.google.gwt.http.client.RequestBuilder) MessageDialogBox(org.pentaho.gwt.widgets.client.dialogs.MessageDialogBox) PromptDialogBox(org.pentaho.gwt.widgets.client.dialogs.PromptDialogBox) Request(com.google.gwt.http.client.Request) HTML(com.google.gwt.user.client.ui.HTML) SolutionFileActionEvent(org.pentaho.mantle.client.events.SolutionFileActionEvent) IDialogCallback(org.pentaho.gwt.widgets.client.dialogs.IDialogCallback) RequestException(com.google.gwt.http.client.RequestException) Response(com.google.gwt.http.client.Response) VerticalPanel(com.google.gwt.user.client.ui.VerticalPanel) RequestCallback(com.google.gwt.http.client.RequestCallback)

Example 100 with Response

use of com.google.gwt.http.client.Response in project pentaho-platform by pentaho.

the class MantleController method executeAdminContent.

private void executeAdminContent() {
    try {
        RequestCallback internalCallback = new RequestCallback() {

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

            public void onResponseReceived(Request request, Response response) {
                JsArray<JsSetting> jsSettings = null;
                try {
                    jsSettings = JsSetting.parseSettingsJson(response.getText());
                } catch (Throwable t) {
                // happens when there are no settings
                }
                if (jsSettings == null) {
                    return;
                }
                for (int i = 0; i < jsSettings.length(); i++) {
                    String content = jsSettings.get(i).getValue();
                    // $NON-NLS-1$
                    StringTokenizer nameValuePairs = new StringTokenizer(content, ";");
                    String perspective = null, content_panel_id = null, content_url = null;
                    for (int j = 0; j < nameValuePairs.countTokens(); j++) {
                        String currentToken = nameValuePairs.tokenAt(j).trim();
                        if (currentToken.startsWith("perspective=")) {
                            // $NON-NLS-1$
                            // $NON-NLS-1$
                            perspective = currentToken.substring("perspective=".length());
                        }
                        if (currentToken.startsWith("content-panel-id=")) {
                            // $NON-NLS-1$
                            // $NON-NLS-1$
                            content_panel_id = currentToken.substring("content-panel-id=".length());
                        }
                        if (currentToken.startsWith("content-url=")) {
                            // $NON-NLS-1$
                            // $NON-NLS-1$
                            content_url = currentToken.substring("content-url=".length());
                        }
                    }
                    if (content_panel_id != null && content_url != null) {
                        overrideContentPanelId = content_panel_id;
                        overrideContentUrl = content_url;
                    }
                    if (perspective != null) {
                        PerspectiveManager.getInstance().setPerspective(perspective);
                    }
                    if (perspective == null && content_panel_id == null && content_url == null) {
                        GwtMessageBox warning = new GwtMessageBox();
                        // $NON-NLS-1$
                        warning.setTitle(Messages.getString("warning"));
                        warning.setMessage(content);
                        warning.setButtons(new Object[GwtMessageBox.ACCEPT]);
                        // $NON-NLS-1$
                        warning.setAcceptLabel(Messages.getString("close"));
                        warning.show();
                    }
                }
            }
        };
        RequestBuilder builder = // $NON-NLS-1$
        new RequestBuilder(RequestBuilder.GET, GWT.getHostPageBaseURL() + "api/mantle/getAdminContent");
        builder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
        // $NON-NLS-1$ //$NON-NLS-2$
        builder.setHeader("accept", "application/json");
        builder.sendRequest(null, internalCallback);
    // TO DO Reset the menuItem click for browser and workspace here?
    } catch (RequestException e) {
    // ignore
    }
}
Also used : Response(com.google.gwt.http.client.Response) JsSetting(org.pentaho.mantle.client.usersettings.JsSetting) StringTokenizer(org.pentaho.gwt.widgets.client.utils.string.StringTokenizer) RequestCallback(com.google.gwt.http.client.RequestCallback) RequestBuilder(com.google.gwt.http.client.RequestBuilder) Request(com.google.gwt.http.client.Request) RequestException(com.google.gwt.http.client.RequestException) GwtMessageBox(org.pentaho.ui.xul.gwt.tags.GwtMessageBox)

Aggregations

Response (com.google.gwt.http.client.Response)168 Request (com.google.gwt.http.client.Request)166 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