Search in sources :

Example 86 with RequestException

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

the class MantleApplication method onMantleSettingsLoaded.

public void onMantleSettingsLoaded(MantleSettingsLoadedEvent event) {
    final HashMap<String, String> settings = event.getSettings();
    final boolean showOnlyPerspective = Boolean.parseBoolean(StringUtils.isEmpty(Window.Location.getParameter("showOnlyPerspective")) ? settings.get("showOnlyPerspective") : Window.Location.getParameter("showOnlyPerspective"));
    final String startupPerspective = StringUtils.isEmpty(Window.Location.getParameter("startupPerspective")) ? settings.get("startupPerspective") : Window.Location.getParameter("startupPerspective");
    mantleRevisionOverride = settings.get("user-console-revision");
    RootPanel.get("pucMenuBar").add(MantleXul.getInstance().getMenubar());
    RootPanel.get("pucPerspectives").add(PerspectiveManager.getInstance());
    RootPanel.get("pucToolBar").add(MantleXul.getInstance().getToolbar());
    RootPanel.get("pucUserDropDown").add(new UserDropDown());
    if (showOnlyPerspective && !StringUtils.isEmpty(startupPerspective)) {
        RootPanel.get("pucHeader").setVisible(false);
        RootPanel.get("pucContent").getElement().getStyle().setTop(0, Unit.PX);
    }
    // update supported file types
    PluginOptionsHelper.buildEnabledOptionsList(settings);
    // show stuff we've created/configured
    contentDeck.add(new Label());
    contentDeck.showWidget(0);
    contentDeck.add(SolutionBrowserPanel.getInstance());
    if (showOnlyPerspective && !StringUtils.isEmpty(startupPerspective)) {
        SolutionBrowserPanel.getInstance().setVisible(false);
    }
    contentDeck.getElement().setId("applicationShell");
    contentDeck.setStyleName("applicationShell");
    // menubar=no,location=no,resizable=yes,scrollbars=no,status=no,width=1200,height=800
    try {
        RootPanel.get("pucContent").add(contentDeck);
    } catch (Throwable t) {
    // onLoad of something is causing problems
    }
    RootPanel.get().add(WaitPopup.getInstance());
    // Add in the overlay panel
    overlayPanel.setVisible(false);
    overlayPanel.setHeight("100%");
    overlayPanel.setWidth("100%");
    overlayPanel.getElement().getStyle().setProperty("zIndex", "1000");
    overlayPanel.getElement().getStyle().setProperty("position", "absolute");
    RootPanel.get().add(overlayPanel, 0, 0);
    String submitOnEnterSetting = settings.get("submit-on-enter-key");
    submitOnEnter = submitOnEnterSetting == null ? submitOnEnter : Boolean.parseBoolean(submitOnEnterSetting);
    try {
        // $NON-NLS-1$
        String restUrl = GWT.getHostPageBaseURL() + "api/repo/files/canAdminister";
        RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.GET, restUrl);
        requestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
        requestBuilder.sendRequest(null, new RequestCallback() {

            @Override
            public void onError(Request arg0, Throwable arg1) {
                MessageDialogBox dialogBox = // $NON-NLS-1$
                new MessageDialogBox(Messages.getString("error"), arg1.getLocalizedMessage(), false, false, true);
                dialogBox.center();
            }

            @Override
            public void onResponseReceived(Request arg0, Response response) {
                Boolean isAdministrator = Boolean.parseBoolean(response.getText());
                SolutionBrowserPanel.getInstance().setAdministrator(isAdministrator);
                try {
                    // $NON-NLS-1$
                    String restUrl2 = GWT.getHostPageBaseURL() + "api/scheduler/canSchedule";
                    RequestBuilder requestBuilder2 = new RequestBuilder(RequestBuilder.GET, restUrl2);
                    requestBuilder2.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
                    requestBuilder2.sendRequest(null, new RequestCallback() {

                        @Override
                        public void onError(Request arg0, Throwable arg1) {
                            MessageDialogBox dialogBox = // $NON-NLS-1$
                            new MessageDialogBox(Messages.getString("error"), arg1.getLocalizedMessage(), false, false, true);
                            dialogBox.center();
                        }

                        public void onResponseReceived(Request arg0, Response response) {
                            Boolean isScheduler = Boolean.parseBoolean(response.getText());
                            SolutionBrowserPanel.getInstance().setScheduler(isScheduler);
                            String numStartupURLsSetting = settings.get("num-startup-urls");
                            if (numStartupURLsSetting != null) {
                                // $NON-NLS-1$
                                int numStartupURLs = Integer.parseInt(numStartupURLsSetting);
                                for (int i = 0; i < numStartupURLs; i++) {
                                    // $NON-NLS-1$
                                    String url = settings.get("startup-url-" + (i + 1));
                                    // $NON-NLS-1$
                                    String name = settings.get("startup-name-" + (i + 1));
                                    if (StringUtils.isEmpty(url) == false) {
                                        // $NON-NLS-1$
                                        url = URL.decodeQueryString(url);
                                        name = URL.decodeQueryString(name);
                                        SolutionBrowserPanel.getInstance().getContentTabPanel().showNewURLTab(name != null ? name : url, url, url, false);
                                    }
                                }
                            }
                            if (SolutionBrowserPanel.getInstance().getContentTabPanel().getWidgetCount() > 0) {
                                SolutionBrowserPanel.getInstance().getContentTabPanel().selectTab(0);
                            }
                            // startup-url on the URL for the app, wins over settings
                            // $NON-NLS-1$
                            String startupURL = Window.Location.getParameter("startup-url");
                            if (startupURL != null && !"".equals(startupURL)) {
                                // $NON-NLS-1$
                                // Spaces were double encoded so that they wouldn't be replaced with '+' when creating a deep
                                // link so when following a deep link we need to replace '%20' with a space even after decoding
                                // $NON-NLS-1$
                                String title = Window.Location.getParameter("name").replaceAll("%20", " ");
                                SolutionBrowserPanel.getInstance().getContentTabPanel().showNewURLTab(title, title, startupURL, false);
                            }
                        }
                    });
                } catch (RequestException e) {
                    MessageDialogBox dialogBox = // $NON-NLS-1$
                    new MessageDialogBox(Messages.getString("error"), e.getLocalizedMessage(), false, false, true);
                    dialogBox.center();
                }
            }
        });
    } catch (RequestException e) {
        MessageDialogBox dialogBox = // $NON-NLS-1$
        new MessageDialogBox(Messages.getString("error"), e.getLocalizedMessage(), false, false, true);
        dialogBox.center();
    }
    if (!StringUtils.isEmpty(startupPerspective)) {
        if (PerspectiveManager.getInstance().isLoaded()) {
            PerspectiveManager.getInstance().setPerspective(startupPerspective);
        } else {
            EventBusUtil.EVENT_BUS.addHandler(PerspectivesLoadedEvent.TYPE, new PerspectivesLoadedEventHandler() {

                public void onPerspectivesLoaded(PerspectivesLoadedEvent event) {
                    PerspectiveManager.getInstance().setPerspective(startupPerspective);
                }
            });
        }
    }
}
Also used : RequestBuilder(com.google.gwt.http.client.RequestBuilder) MessageDialogBox(org.pentaho.gwt.widgets.client.dialogs.MessageDialogBox) PerspectivesLoadedEventHandler(org.pentaho.mantle.client.events.PerspectivesLoadedEventHandler) Label(com.google.gwt.user.client.ui.Label) Request(com.google.gwt.http.client.Request) UserDropDown(org.pentaho.mantle.client.ui.UserDropDown) RequestException(com.google.gwt.http.client.RequestException) Response(com.google.gwt.http.client.Response) PerspectivesLoadedEvent(org.pentaho.mantle.client.events.PerspectivesLoadedEvent) RequestCallback(com.google.gwt.http.client.RequestCallback)

Example 87 with RequestException

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

the class ContentCleanerPanel method deleteContentCleaner.

private void deleteContentCleaner(JsJob jsJob) {
    if (jsJob == null || StringUtils.isEmpty(jsJob.getJobId())) {
        activate();
        return;
    }
    // $NON-NLS-1$
    final String url = GWT.getHostPageBaseURL() + "api/scheduler/removeJob";
    RequestBuilder builder = new RequestBuilder(RequestBuilder.DELETE, url);
    builder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
    // $NON-NLS-1$//$NON-NLS-2$
    builder.setHeader("Content-Type", "application/json");
    JSONObject startJobRequest = new JSONObject();
    // $NON-NLS-1$
    startJobRequest.put("jobId", new JSONString(jsJob.getJobId()));
    try {
        builder.sendRequest(startJobRequest.toString(), new RequestCallback() {

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

            public void onResponseReceived(Request request, Response response) {
                activate();
            }
        });
    } catch (RequestException re) {
        Window.alert(re.getMessage());
    }
}
Also used : Response(com.google.gwt.http.client.Response) RequestBuilder(com.google.gwt.http.client.RequestBuilder) JSONObject(com.google.gwt.json.client.JSONObject) RequestCallback(com.google.gwt.http.client.RequestCallback) Request(com.google.gwt.http.client.Request) JSONString(com.google.gwt.json.client.JSONString) RequestException(com.google.gwt.http.client.RequestException) JSONString(com.google.gwt.json.client.JSONString)

Example 88 with RequestException

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

the class ContentCleanerPanel method activate.

public void activate() {
    clear();
    String moduleBaseURL = GWT.getModuleBaseURL();
    String moduleName = GWT.getModuleName();
    String contextURL = moduleBaseURL.substring(0, moduleBaseURL.lastIndexOf(moduleName));
    RequestBuilder scheduleFileRequestBuilder = new RequestBuilder(RequestBuilder.GET, contextURL + "api/scheduler/getContentCleanerJob?cb=" + System.currentTimeMillis());
    scheduleFileRequestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
    // $NON-NLS-1$//$NON-NLS-2$
    scheduleFileRequestBuilder.setHeader("Content-Type", "application/json");
    // $NON-NLS-1$//$NON-NLS-2$
    scheduleFileRequestBuilder.setHeader("accept", "application/json");
    try {
        scheduleFileRequestBuilder.sendRequest("", new RequestCallback() {

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

            public void onResponseReceived(Request request, Response response) {
                final TextBox nowTextBox = new TextBox();
                nowTextBox.setWidth("24px");
                nowTextBox.getElement().getStyle().setPadding(5, Unit.PX);
                nowTextBox.getElement().getStyle().setMarginLeft(5, Unit.PX);
                nowTextBox.getElement().getStyle().setMarginRight(5, Unit.PX);
                final TextBox scheduleTextBox = new TextBox();
                scheduleTextBox.setVisibleLength(4);
                JsJob tmpJsJob = parseJsonJob(JsonUtils.escapeJsonForEval(response.getText()));
                boolean fakeJob = false;
                if (tmpJsJob == null) {
                    tmpJsJob = createJsJob();
                    fakeJob = true;
                }
                final JsJob jsJob = tmpJsJob;
                if (jsJob != null) {
                    scheduleTextBox.setValue("" + (Long.parseLong(jsJob.getJobParamValue("age")) / 86400L));
                } else {
                    scheduleTextBox.setText("180");
                }
                scheduleTextBox.addChangeHandler(new ChangeHandler() {

                    public void onChange(ChangeEvent event) {
                        if (jsJob != null) {
                            JsArray<JsJobParam> params = jsJob.getJobParams();
                            for (int i = 0; i < params.length(); i++) {
                                if (params.get(i).getName().equals("age")) {
                                    params.get(i).setValue("" + (Long.parseLong(scheduleTextBox.getText()) * 86400L));
                                    break;
                                }
                            }
                        }
                    }
                });
                Label settingsLabel = new Label(Messages.getString("settings"));
                settingsLabel.setStyleName("pentaho-fieldgroup-major");
                add(settingsLabel, DockPanel.NORTH);
                VerticalPanel nowPanelWrapper = new VerticalPanel();
                Label deleteNowLabel = new Label(Messages.getString("deleteGeneratedFilesNow"));
                deleteNowLabel.getElement().getStyle().setPaddingTop(15, Unit.PX);
                deleteNowLabel.setStyleName("pentaho-fieldgroup-minor");
                nowPanelWrapper.add(deleteNowLabel);
                HorizontalPanel nowLabelPanel = new HorizontalPanel();
                nowLabelPanel.getElement().getStyle().setPaddingTop(10, Unit.PX);
                nowLabelPanel.getElement().getStyle().setPaddingBottom(10, Unit.PX);
                Label deleteGeneratedFilesOlderThan = new Label(Messages.getString("deleteGeneratedFilesOlderThan"));
                deleteGeneratedFilesOlderThan.getElement().getStyle().setPaddingTop(7, Unit.PX);
                nowLabelPanel.add(deleteGeneratedFilesOlderThan);
                nowLabelPanel.add(nowTextBox);
                nowTextBox.setText("180");
                Label days = new Label(Messages.getString("daysDot"));
                days.getElement().getStyle().setPaddingTop(7, Unit.PX);
                nowLabelPanel.add(days);
                Button deleteNowButton = new Button(Messages.getString("deleteNow"));
                deleteNowButton.setStylePrimaryName("pentaho-button");
                deleteNowButton.addStyleName("first");
                deleteNowButton.addClickHandler(new ClickHandler() {

                    public void onClick(ClickEvent event) {
                        MessageDialogBox warning = new MessageDialogBox(Messages.getString("deleteNow"), Messages.getString("confirmDeleteGeneratedContentNow"), false, false, true, Messages.getString("yes"), null, Messages.getString("no"));
                        warning.setCallback(new IDialogCallback() {

                            @Override
                            public void okPressed() {
                                deleteContentNow(Long.parseLong(nowTextBox.getValue()) * 86400L);
                            }

                            @Override
                            public void cancelPressed() {
                            }
                        });
                        warning.center();
                    }
                });
                nowPanelWrapper.add(nowLabelPanel);
                nowPanelWrapper.add(deleteNowButton);
                add(nowPanelWrapper, DockPanel.NORTH);
                // scheduled
                VerticalPanel scheduledPanel = new VerticalPanel();
                Label deleteScheduleLabel = new Label(Messages.getString("scheduleDeletionOfGeneratedFiles"));
                deleteScheduleLabel.setStyleName("pentaho-fieldgroup-minor");
                deleteScheduleLabel.getElement().getStyle().setPaddingTop(15, Unit.PX);
                scheduledPanel.add(deleteScheduleLabel);
                Label descLabel;
                if (!fakeJob) {
                    String desc = jsJob.getJobTrigger().getDescription();
                    descLabel = new Label(desc);
                    scheduledPanel.add(descLabel);
                } else {
                    descLabel = new Label(Messages.getString("generatedFilesAreNotScheduledToBeDeleted"));
                    scheduledPanel.add(descLabel);
                }
                descLabel.getElement().getStyle().setPaddingTop(10, Unit.PX);
                descLabel.getElement().getStyle().setPaddingBottom(10, Unit.PX);
                Button editScheduleButton = new Button(Messages.getString("edit"));
                if (fakeJob) {
                    editScheduleButton.setText(Messages.getString("scheduleDeletion"));
                }
                Button deleteScheduleButton = new Button(Messages.getString("cancelSchedule"));
                deleteScheduleButton.setStylePrimaryName("pentaho-button");
                deleteScheduleButton.addStyleName("last");
                deleteScheduleButton.addClickHandler(new ClickHandler() {

                    public void onClick(ClickEvent event) {
                        deleteContentCleaner(jsJob);
                    }
                });
                editScheduleButton.setStylePrimaryName("pentaho-button");
                editScheduleButton.addStyleName("first");
                editScheduleButton.addClickHandler(new ClickHandler() {

                    public void onClick(ClickEvent event) {
                        IDialogCallback callback = new IDialogCallback() {

                            public void okPressed() {
                                deleteContentCleaner(jsJob);
                            }

                            public void cancelPressed() {
                            }
                        };
                        HorizontalPanel scheduleLabelPanel = new HorizontalPanel();
                        scheduleLabelPanel.add(new Label(Messages.getString("deleteGeneratedFilesOlderThan"), false));
                        scheduleLabelPanel.add(scheduleTextBox);
                        scheduleLabelPanel.add(new Label(Messages.getString("daysUsingTheFollowingRules"), false));
                        ScheduleRecurrenceDialog editSchedule = new ScheduleRecurrenceDialog(null, jsJob, callback, false, false, AbstractWizardDialog.ScheduleDialogType.SCHEDULER);
                        editSchedule.setShowSuccessDialog(false);
                        editSchedule.addCustomPanel(scheduleLabelPanel, DockPanel.NORTH);
                        editSchedule.center();
                    }
                });
                HorizontalPanel scheduleButtonPanel = new HorizontalPanel();
                scheduleButtonPanel.add(editScheduleButton);
                if (!fakeJob) {
                    scheduleButtonPanel.add(deleteScheduleButton);
                }
                scheduledPanel.add(scheduleButtonPanel);
                add(scheduledPanel, DockPanel.NORTH);
                VerticalPanel fillPanel = new VerticalPanel();
                add(fillPanel, DockPanel.NORTH);
                fillPanel.getElement().getParentElement().getStyle().setHeight(100, Unit.PCT);
            }
        });
    } catch (RequestException re) {
    // ignored
    }
}
Also used : RequestBuilder(com.google.gwt.http.client.RequestBuilder) MessageDialogBox(org.pentaho.gwt.widgets.client.dialogs.MessageDialogBox) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) Request(com.google.gwt.http.client.Request) Label(com.google.gwt.user.client.ui.Label) JsJobParam(org.pentaho.mantle.client.workspace.JsJobParam) JSONString(com.google.gwt.json.client.JSONString) TextBox(com.google.gwt.user.client.ui.TextBox) 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) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) RequestCallback(com.google.gwt.http.client.RequestCallback) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) Button(com.google.gwt.user.client.ui.Button) HorizontalPanel(com.google.gwt.user.client.ui.HorizontalPanel) JsJob(org.pentaho.mantle.client.workspace.JsJob) ScheduleRecurrenceDialog(org.pentaho.mantle.client.dialogs.scheduling.ScheduleRecurrenceDialog)

Example 89 with RequestException

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

the class EmailAdminPanelController method setEmailConfig.

// -- Remote Calls.
private void setEmailConfig() {
    String serviceUrl = GWT.getHostPageBaseURL() + "api/emailconfig/setEmailConfig";
    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");
        executableTypesRequestBuilder.sendRequest(emailConfig.getJSONString(), new RequestCallback() {

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

            public void onResponseReceived(Request request, Response response) {
                setDirty(false);
            }
        });
    } 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)

Example 90 with RequestException

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

the class UserRolesAdminPanelController method deleteRoles.

public void deleteRoles() {
    StringBuilder selectedRoles = new StringBuilder();
    for (int i = 0; i < rolesListBox.getItemCount(); i++) {
        if (rolesListBox.isItemSelected(i)) {
            selectedRoles.append(encodeUri(rolesListBox.getValue(i) + delimiter));
        }
    }
    String serviceUrl = GWT.getHostPageBaseURL() + "api/userroledao/deleteRoles?roleNames=" + selectedRoles.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);
                availableMembersListBox.clear();
                selectedMembersListBox.clear();
                updateHelperDiv(HorizontalScrollWrapper.getListBoxWrapperUIId(availableMembersListBox));
                updateHelperDiv(HorizontalScrollWrapper.getListBoxWrapperUIId(selectedMembersListBox));
                initializeRoles(null, "api/userroledao/roles", rolesListBox);
                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)

Aggregations

RequestException (com.google.gwt.http.client.RequestException)162 RequestCallback (com.google.gwt.http.client.RequestCallback)155 Response (com.google.gwt.http.client.Response)154 Request (com.google.gwt.http.client.Request)153 RequestBuilder (com.google.gwt.http.client.RequestBuilder)106 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