Search in sources :

Example 36 with RequestException

use of com.google.gwt.http.client.RequestException in project kie-wb-common by kiegroup.

the class FooterPresenter method setupUrl.

void setupUrl(final String url) {
    final Command onSuccess = makeOnSuccess(url);
    final Command onError = makeOnError();
    try {
        makeRequest(url, onSuccess, onError).send();
    } catch (final RequestException e) {
        onError.execute();
    }
}
Also used : Command(org.uberfire.mvp.Command) RequestException(com.google.gwt.http.client.RequestException)

Example 37 with RequestException

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

the class SchedulesPanel method controlJobs.

private void controlJobs(final Set<JsJob> jobs, String function, final Method method, final boolean refreshData) {
    for (final JsJob job : jobs) {
        RequestBuilder builder = createRequestBuilder(method, "api/scheduler/" + function);
        builder.setHeader(HTTP.CONTENT_TYPE, JSON_CONTENT_TYPE);
        JSONObject startJobRequest = new JSONObject();
        startJobRequest.put("jobId", new JSONString(job.getJobId()));
        try {
            builder.sendRequest(startJobRequest.toString(), new RequestCallback() {

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

                public void onResponseReceived(Request request, Response response) {
                    final String jobState = response.getText();
                    job.setState(jobState);
                    table.redraw();
                    updateJobScheduleButtonStyle(jobState);
                    if (refreshData) {
                        refresh();
                    }
                }
            });
        } catch (RequestException e) {
        // 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) JSONObject(com.google.gwt.json.client.JSONObject) EmptyRequestCallback(org.pentaho.mantle.client.EmptyRequestCallback) 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 38 with RequestException

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

the class SchedulesPanel method refresh.

public void refresh() {
    String moduleBaseURL = GWT.getModuleBaseURL();
    String moduleName = GWT.getModuleName();
    String contextURL = moduleBaseURL.substring(0, moduleBaseURL.lastIndexOf(moduleName));
    final String apiEndpoint = "api/scheduler/getJobs";
    RequestBuilder executableTypesRequestBuilder = createRequestBuilder(RequestBuilder.GET, apiEndpoint, contextURL);
    executableTypesRequestBuilder.setHeader(HTTP_ACCEPT_HEADER, JSON_CONTENT_TYPE);
    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) {
                    allJobs = parseJson(JsonUtils.escapeJsonForEval(response.getText()));
                    filterAndShowData();
                }
            }
        });
    } catch (RequestException e) {
    // 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) EmptyRequestCallback(org.pentaho.mantle.client.EmptyRequestCallback) 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)

Example 39 with RequestException

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

the class SchedulesPanel method canAccessJobRequest.

private void canAccessJobRequest(final JsJob job, RequestCallback callback) {
    final String jobId = SolutionBrowserPanel.pathToId(job.getFullResourceName());
    final String apiEndpoint = "api/repo/files/" + jobId + "/canAccess?cb=" + System.currentTimeMillis() + "&permissions=" + READ_PERMISSION;
    final RequestBuilder accessBuilder = createRequestBuilder(RequestBuilder.GET, apiEndpoint);
    try {
        accessBuilder.sendRequest(null, callback);
    } catch (RequestException re) {
    // noop
    }
}
Also used : RequestBuilder(com.google.gwt.http.client.RequestBuilder) CsrfRequestBuilder(org.pentaho.mantle.client.csrf.CsrfRequestBuilder) JSONString(com.google.gwt.json.client.JSONString) RequestException(com.google.gwt.http.client.RequestException)

Example 40 with RequestException

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

the class SchedulesPanel method canAccessJobListRequest.

private void canAccessJobListRequest(final Set<JsJob> jobs, RequestCallback callback) {
    final JSONArray jobNameList = new JSONArray();
    int idx = 0;
    for (JsJob job : jobs) {
        jobNameList.set(idx++, new JSONString(job.getFullResourceName()));
    }
    final JSONObject payload = new JSONObject();
    payload.put("strings", jobNameList);
    final String accessListEndpoint = "api/repo/files/pathsAccessList?cb=" + System.currentTimeMillis();
    RequestBuilder accessListBuilder = createRequestBuilder(RequestBuilder.POST, accessListEndpoint);
    accessListBuilder.setHeader(HTTP.CONTENT_TYPE, JSON_CONTENT_TYPE);
    accessListBuilder.setHeader(HTTP_ACCEPT_HEADER, JSON_CONTENT_TYPE);
    try {
        accessListBuilder.sendRequest(payload.toString(), callback);
    } catch (RequestException re) {
    // noop
    }
}
Also used : JSONObject(com.google.gwt.json.client.JSONObject) RequestBuilder(com.google.gwt.http.client.RequestBuilder) CsrfRequestBuilder(org.pentaho.mantle.client.csrf.CsrfRequestBuilder) JSONArray(com.google.gwt.json.client.JSONArray) JSONString(com.google.gwt.json.client.JSONString) RequestException(com.google.gwt.http.client.RequestException) JSONString(com.google.gwt.json.client.JSONString)

Aggregations

RequestException (com.google.gwt.http.client.RequestException)164 RequestCallback (com.google.gwt.http.client.RequestCallback)154 Response (com.google.gwt.http.client.Response)153 Request (com.google.gwt.http.client.Request)152 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 CsrfRequestBuilder (org.pentaho.mantle.client.csrf.CsrfRequestBuilder)17 MessageDialogBox (org.pentaho.gwt.widgets.client.dialogs.MessageDialogBox)16 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