Search in sources :

Example 1 with NewScheduleDialog

use of org.pentaho.mantle.client.dialogs.scheduling.NewScheduleDialog in project pentaho-platform by pentaho.

the class SchedulesPanel method editJob.

private void editJob(JsJob editJob) {
    final String url = GWT.getHostPageBaseURL() + "api/scheduler/jobinfo?jobId=" + URL.encodeQueryString(editJob.getJobId());
    RequestBuilder executableTypesRequestBuilder = new RequestBuilder(RequestBuilder.GET, url);
    executableTypesRequestBuilder.setHeader("accept", "application/json");
    executableTypesRequestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
    try {
        executableTypesRequestBuilder.sendRequest(null, new RequestCallback() {

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

            public void onResponseReceived(Request request, Response response) {
                if (response.getStatusCode() == Response.SC_OK) {
                    final JsJob jsJob = parseJsonJob(JsonUtils.escapeJsonForEval(response.getText()));
                    // check email is setup
                    RequestBuilder emailValidRequest = new RequestBuilder(RequestBuilder.GET, GWT.getHostPageBaseURL() + "api/emailconfig/isValid");
                    emailValidRequest.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
                    emailValidRequest.setHeader("accept", "text/plain");
                    try {
                        emailValidRequest.sendRequest(null, new RequestCallback() {

                            public void onError(Request request, Throwable exception) {
                                MessageDialogBox dialogBox = // $NON-NLS-1$
                                new MessageDialogBox(Messages.getString("error"), exception.toString(), false, false, true);
                                dialogBox.center();
                            }

                            public void onResponseReceived(Request request, Response response) {
                                if (response.getStatusCode() == Response.SC_OK) {
                                    final boolean isEmailConfValid = Boolean.parseBoolean(response.getText());
                                    final NewScheduleDialog schedDialog = new NewScheduleDialog(jsJob, scheduleDialogCallback, isEmailConfValid);
                                    schedDialog.center();
                                }
                            }
                        });
                    } catch (RequestException e) {
                    // showError(e);
                    }
                } else {
                    MessageDialogBox dialogBox = new MessageDialogBox(Messages.getString("error"), Messages.getString("serverErrorColon") + " " + response.getStatusCode(), false, false, // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
                    true);
                    dialogBox.center();
                }
            }
        });
    } catch (RequestException e) {
    // showError(e);
    }
}
Also used : Response(com.google.gwt.http.client.Response) RequestBuilder(com.google.gwt.http.client.RequestBuilder) RequestCallback(com.google.gwt.http.client.RequestCallback) MessageDialogBox(org.pentaho.gwt.widgets.client.dialogs.MessageDialogBox) Request(com.google.gwt.http.client.Request) JSONString(com.google.gwt.json.client.JSONString) RequestException(com.google.gwt.http.client.RequestException) NewScheduleDialog(org.pentaho.mantle.client.dialogs.scheduling.NewScheduleDialog)

Aggregations

Request (com.google.gwt.http.client.Request)1 RequestBuilder (com.google.gwt.http.client.RequestBuilder)1 RequestCallback (com.google.gwt.http.client.RequestCallback)1 RequestException (com.google.gwt.http.client.RequestException)1 Response (com.google.gwt.http.client.Response)1 JSONString (com.google.gwt.json.client.JSONString)1 MessageDialogBox (org.pentaho.gwt.widgets.client.dialogs.MessageDialogBox)1 NewScheduleDialog (org.pentaho.mantle.client.dialogs.scheduling.NewScheduleDialog)1