List of usage examples for com.google.gwt.http.client RequestBuilder GET
Method GET
To view the source code for com.google.gwt.http.client RequestBuilder GET.
Click Source Link
From source file:org.pentaho.mantle.client.dialogs.scheduling.ScheduleEditor.java
License:Open Source License
private void populateTimeZonePicker() { String url = ScheduleHelper.getFullyQualifiedURL() + "api/system/timezones"; //$NON-NLS-1$ RequestBuilder timeZonesRequest = new RequestBuilder(RequestBuilder.GET, url); timeZonesRequest.setHeader("accept", "application/json"); //$NON-NLS-1$ //$NON-NLS-2$ timeZonesRequest.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT"); try {//from w ww . ja va 2 s . c om timeZonesRequest.sendRequest(null, new RequestCallback() { @Override public void onResponseReceived(Request request, Response response) { timeZonePicker.clear(); String responseText = response.getText(); JSONValue value = JSONParser.parseLenient(responseText); JSONObject object = value.isObject(); value = object.get("timeZones"); JSONValue serverTZvalue = object.get("serverTzId"); JSONString serverTZIdString = serverTZvalue.isString(); String serverTZId = serverTZIdString.stringValue(); object = value.isObject(); value = object.get("entry"); JSONArray timeZonesJSONArray = value.isArray(); for (int i = 0; i < timeZonesJSONArray.size(); i++) { JSONValue entryValue = timeZonesJSONArray.get(i); JSONObject entryObject = entryValue.isObject(); JSONValue keyValue = entryObject.get("key"); JSONValue theValue = entryObject.get("value"); String key = keyValue.isString().stringValue(); String valueForKey = theValue.isString().stringValue(); timeZonePicker.addItem(valueForKey, key); } for (int i = 0; i < timeZonePicker.getItemCount(); i++) { if (timeZonePicker.getValue(i).equalsIgnoreCase(serverTZId)) { timeZonePicker.setSelectedIndex(i); break; } } } @Override public void onError(Request request, Throwable exception) { // TODO Auto-generated method stub } }); } catch (RequestException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:org.pentaho.mantle.client.dialogs.scheduling.ScheduleHelper.java
License:Open Source License
public static void showScheduleDialog(final String fileNameWithPath, final IDialogCallback callback) { final SolutionFileActionEvent event = new SolutionFileActionEvent(); event.setAction(ScheduleHelper.class.getName()); try {/*from w ww .ja va2 s . c o m*/ final String url = ScheduleHelper.getFullyQualifiedURL() + "api/mantle/isAuthenticated"; //$NON-NLS-1$ RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.GET, url); requestBuilder.setHeader("accept", "text/plain"); requestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT"); requestBuilder.sendRequest(null, new RequestCallback() { public void onError(Request request, Throwable caught) { MantleLoginDialog.performLogin(new AsyncCallback<Boolean>() { public void onFailure(Throwable caught) { } public void onSuccess(Boolean result) { showScheduleDialog(fileNameWithPath, callback); } }); } public void onResponseReceived(Request request, Response response) { String moduleBaseURL = GWT.getModuleBaseURL(); String moduleName = GWT.getModuleName(); final String contextURL = moduleBaseURL.substring(0, moduleBaseURL.lastIndexOf(moduleName)); RequestBuilder emailValidRequest = new RequestBuilder(RequestBuilder.GET, contextURL + "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 = new MessageDialogBox(Messages.getString("error"), //$NON-NLS-1$ exception.toString(), false, false, true); dialogBox.center(); event.setMessage(exception.getLocalizedMessage()); EventBusUtil.EVENT_BUS.fireEvent(event); } public void onResponseReceived(Request request, Response response) { if (response.getStatusCode() == Response.SC_OK) { final boolean isEmailConfValid = Boolean.parseBoolean(response.getText()); NewScheduleDialog dialog = new NewScheduleDialog(fileNameWithPath, callback, isEmailConfValid); dialog.center(); event.setMessage("Open"); EventBusUtil.EVENT_BUS.fireEvent(event); } } }); } catch (RequestException e) { MessageDialogBox dialogBox = new MessageDialogBox(Messages.getString("error"), e.toString(), //$NON-NLS-1$ false, false, true); dialogBox.center(); event.setMessage(e.getLocalizedMessage()); EventBusUtil.EVENT_BUS.fireEvent(event); } } }); } catch (RequestException e) { Window.alert(e.getMessage()); event.setMessage(e.getLocalizedMessage()); EventBusUtil.EVENT_BUS.fireEvent(event); } }
From source file:org.pentaho.mantle.client.dialogs.scheduling.ScheduleHelper.java
License:Open Source License
public static void createSchedule(final RepositoryFile repositoryFile, final IDialogCallback callback) { AbstractCommand scheduleCommand = new AbstractCommand() { protected void performOperation() { // hit the server and check: isScheduleAllowed final String url = ScheduleHelper.getFullyQualifiedURL() + "api/scheduler/isScheduleAllowed?id=" //$NON-NLS-1$ + repositoryFile.getId(); RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.GET, url); requestBuilder.setHeader("accept", "text/plain"); requestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT"); final MessageDialogBox errorDialog = new MessageDialogBox(Messages.getString("error"), //$NON-NLS-1$ Messages.getString("noSchedulePermission"), false, false, true); //$NON-NLS-1$ try { requestBuilder.sendRequest(null, new RequestCallback() { public void onError(Request request, Throwable caught) { errorDialog.center(); }/*from w ww . j a v a 2 s.co m*/ public void onResponseReceived(Request request, Response response) { if ("true".equalsIgnoreCase(response.getText())) { callback.okPressed(); } else { errorDialog.center(); } } }); } catch (RequestException re) { errorDialog.center(); } } protected void performOperation(boolean feedback) { performOperation(); } }; scheduleCommand.execute(); }
From source file:org.pentaho.mantle.client.dialogs.scheduling.ScheduleHelper.java
License:Open Source License
/** * The passed in URL has all the parameters set for background execution. We simply call GET on the URL and * handle the response object. If the response object contains a particular string then we display success * message box./* ww w . j a v a 2 s. com*/ * * @param url * Complete url with all the parameters set for scheduling a job in the background. */ private static void runInBackground(final String url) { 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) { MessageDialogBox dialogBox = new MessageDialogBox(Messages.getString("error"), //$NON-NLS-1$ Messages.getString("couldNotBackgroundExecute"), false, false, true); //$NON-NLS-1$ dialogBox.center(); } public void onResponseReceived(Request request, Response response) { /* * We are checking for this specific string because if the job was scheduled successfully by * QuartzBackgroundExecutionHelper then the response is an html that contains the specific string. We * have coded this way because we did not want to touch the old way. */ if ("true".equals(response.getHeader("background_execution"))) { MessageDialogBox dialogBox = new MessageDialogBox(Messages.getString("info"), //$NON-NLS-1$ Messages.getString("backgroundJobScheduled"), false, false, true); //$NON-NLS-1$ dialogBox.center(); } } }); } catch (RequestException e) { MessageDialogBox dialogBox = new MessageDialogBox(Messages.getString("error"), //$NON-NLS-1$ Messages.getString("couldNotBackgroundExecute"), false, false, true); //$NON-NLS-1$ dialogBox.center(); } }
From source file:org.pentaho.mantle.client.dialogs.scheduling.ScheduleOutputLocationDialogExecutor.java
License:Open Source License
private RequestBuilder createParametersChecker(String urlPath) { RequestBuilder scheduleFileRequestBuilder = null; if ((urlPath != null) && (urlPath.endsWith("xaction"))) { scheduleFileRequestBuilder = new RequestBuilder(RequestBuilder.GET, ScheduleHelper.getFullyQualifiedURL() + "api/repos/" + urlPath + "/parameterUi"); } else {//from w ww .ja v a 2 s .c o m scheduleFileRequestBuilder = new RequestBuilder(RequestBuilder.GET, ScheduleHelper.getFullyQualifiedURL() + "api/repo/files/" + urlPath + "/parameterizable"); } scheduleFileRequestBuilder.setHeader("accept", "text/plain"); //$NON-NLS-1$ //$NON-NLS-2$ scheduleFileRequestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT"); return scheduleFileRequestBuilder; }
From source file:org.pentaho.mantle.client.dialogs.scheduling.ScheduleOutputLocationDialogExecutor.java
License:Open Source License
protected void performOperation(boolean feedback) { final String filePath = reportFile; String urlPath = NameUtils.URLEncode(NameUtils.encodeRepositoryPath(filePath)); RequestBuilder scheduleFileRequestBuilder = createParametersChecker(urlPath); final boolean isXAction = isXAction(urlPath); try {// ww w .java 2 s . c o m scheduleFileRequestBuilder.sendRequest(null, new RequestCallback() { public void onError(Request request, Throwable exception) { MessageDialogBox dialogBox = new MessageDialogBox(Messages.getString("error"), //$NON-NLS-1$ exception.toString(), false, false, true); dialogBox.center(); } public void onResponseReceived(Request request, Response response) { if (response.getStatusCode() == Response.SC_OK) { final JSONObject scheduleRequest = new JSONObject(); scheduleRequest.put("inputFile", new JSONString(filePath)); //$NON-NLS-1$ // Set job name if (StringUtils.isEmpty(getOutputName())) { scheduleRequest.put("jobName", JSONNull.getInstance()); //$NON-NLS-1$ } else { scheduleRequest.put("jobName", new JSONString(getOutputName())); //$NON-NLS-1$ } // Set output path location if (StringUtils.isEmpty(getOutputLocationPath())) { scheduleRequest.put("outputFile", JSONNull.getInstance()); //$NON-NLS-1$ } else { scheduleRequest.put("outputFile", new JSONString(getOutputLocationPath())); //$NON-NLS-1$ } // BISERVER-9321 scheduleRequest.put("runInBackground", JSONBoolean.getInstance(true)); String responseMessage = response.getText(); final boolean hasParams = hasParameters(responseMessage, isXAction); RequestBuilder emailValidRequest = new RequestBuilder(RequestBuilder.GET, ScheduleHelper.getFullyQualifiedURL() + "api/emailconfig/isValid"); //$NON-NLS-1$ emailValidRequest.setHeader("accept", "text/plain"); //$NON-NLS-1$ //$NON-NLS-2$ emailValidRequest.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT"); try { emailValidRequest.sendRequest(null, new RequestCallback() { public void onError(Request request, Throwable exception) { MessageDialogBox dialogBox = new MessageDialogBox(Messages.getString("error"), //$NON-NLS-1$ 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()); // force false for now, I have a feeling PM is going to want this, making it easy to turn back // on final boolean isEmailConfValid = false; if (hasParams) { ScheduleParamsDialog dialog = new ScheduleParamsDialog(filePath, scheduleRequest, isEmailConfValid); dialog.center(); dialog.setAfterResponseCallback(scheduleParamsDialogCallback); } else if (isEmailConfValid) { ScheduleEmailDialog scheduleEmailDialog = new ScheduleEmailDialog(null, filePath, scheduleRequest, null, null); scheduleEmailDialog.center(); } else { // just run it RequestBuilder scheduleFileRequestBuilder = new RequestBuilder( RequestBuilder.POST, ScheduleHelper.getFullyQualifiedURL() + "api/scheduler/job"); //$NON-NLS-1$ scheduleFileRequestBuilder.setHeader("Content-Type", //$NON-NLS-1$ "application/json"); //$NON-NLS-1$ scheduleFileRequestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT"); try { scheduleFileRequestBuilder.sendRequest(scheduleRequest.toString(), new RequestCallback() { @Override public void onError(Request request, Throwable exception) { MessageDialogBox dialogBox = new MessageDialogBox( Messages.getString("error"), //$NON-NLS-1$ exception.toString(), false, false, true); dialogBox.center(); } @Override public void onResponseReceived(Request request, Response response) { if (response.getStatusCode() == 200) { MessageDialogBox dialogBox = new MessageDialogBox( Messages.getString("runInBackground"), //$NON-NLS-1$ Messages.getString( "backgroundExecutionStarted"), //$NON-NLS-1$ false, false, true); dialogBox.center(); } else { MessageDialogBox dialogBox = new MessageDialogBox( Messages.getString("error"), //$NON-NLS-1$ Messages.getString("serverErrorColon") //$NON-NLS-1$ + " " //$NON-NLS-1$ + response.getStatusCode(), false, false, true); dialogBox.center(); } } }); } catch (RequestException e) { MessageDialogBox dialogBox = new MessageDialogBox( Messages.getString("error"), e.toString(), //$NON-NLS-1$ false, false, true); dialogBox.center(); } } } } }); } catch (RequestException e) { MessageDialogBox dialogBox = new MessageDialogBox(Messages.getString("error"), //$NON-NLS-1$ e.toString(), false, false, true); dialogBox.center(); } } else { MessageDialogBox dialogBox = new MessageDialogBox(Messages.getString("error"), //$NON-NLS-1$ Messages.getString("serverErrorColon") + " " + response.getStatusCode(), false, //$NON-NLS-1$//$NON-NLS-2$ false, true); dialogBox.center(); } } }); } catch (RequestException e) { MessageDialogBox dialogBox = new MessageDialogBox(Messages.getString("error"), e.toString(), false, //$NON-NLS-1$ false, true); dialogBox.center(); } }
From source file:org.pentaho.mantle.client.dialogs.scheduling.ScheduleParamsDialog.java
License:Open Source License
private void showScheduleEmailDialog(final JSONArray scheduleParams) { try {//from w w w . j av a 2 s . c om final String url = ScheduleHelper.getFullyQualifiedURL() + "api/mantle/isAuthenticated"; //$NON-NLS-1$ RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.GET, url); requestBuilder.setHeader("accept", "text/plain"); requestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT"); requestBuilder.sendRequest(null, new RequestCallback() { @Override public void onError(Request request, Throwable caught) { MantleLoginDialog.performLogin(new AsyncCallback<Boolean>() { @Override public void onFailure(Throwable caught) { } @Override public void onSuccess(Boolean result) { showScheduleEmailDialog(scheduleParams); } }); } @Override public void onResponseReceived(Request request, Response response) { if (scheduleEmailDialog == null) { scheduleEmailDialog = new ScheduleEmailDialog(ScheduleParamsDialog.this, filePath, jobSchedule, scheduleParams, editJob); scheduleEmailDialog.setCallback(callback); } else { scheduleEmailDialog.setScheduleParams(scheduleParams); scheduleEmailDialog.setJobSchedule(jobSchedule); } scheduleEmailDialog.center(); hide(); } }); } catch (RequestException e) { Window.alert(e.getMessage()); } }
From source file:org.pentaho.mantle.client.dialogs.scheduling.ScheduleRecurrenceDialog.java
License:Open Source License
private void constructDialog(String filePath, String outputLocation, String scheduleName, boolean hasParams, boolean isEmailConfValid, JsJob jsJob) { this.hasParams = hasParams; this.filePath = filePath; this.isEmailConfValid = isEmailConfValid; this.outputLocation = outputLocation; this.scheduleName = scheduleName; scheduleEditorWizardPanel = new ScheduleEditorWizardPanel(getDialogType()); scheduleEditor = scheduleEditorWizardPanel.getScheduleEditor(); String url = ScheduleHelper.getFullyQualifiedURL() + "api/scheduler/blockout/hasblockouts?ts=" //$NON-NLS-1$ + System.currentTimeMillis(); RequestBuilder hasBlockoutsRequest = new RequestBuilder(RequestBuilder.GET, url); hasBlockoutsRequest.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT"); hasBlockoutsRequest.setHeader("accept", "text/plain"); try {//from ww w .j av a2s .c o m hasBlockoutsRequest.sendRequest(url, new RequestCallback() { @Override public void onError(Request request, Throwable exception) { MessageDialogBox dialogBox = new MessageDialogBox(Messages.getString("error"), //$NON-NLS-1$ exception.toString(), false, false, true); dialogBox.center(); } @Override public void onResponseReceived(Request request, Response response) { Boolean hasBlockouts = Boolean.valueOf(response.getText()); if (hasBlockouts) { scheduleEditor.setBlockoutButtonHandler(new ClickHandler() { @Override public void onClick(final ClickEvent clickEvent) { PromptDialogBox box = new PromptDialogBox(Messages.getString("blockoutTimes"), Messages.getString("close"), null, null, false, true, new BlockoutPanel(false)); box.center(); } }); } scheduleEditor.getBlockoutCheckButton().setVisible(hasBlockouts); } }); } catch (RequestException e) { MessageDialogBox dialogBox = new MessageDialogBox(Messages.getString("error"), e.toString(), //$NON-NLS-1$ false, false, true); dialogBox.center(); } IWizardPanel[] wizardPanels = { scheduleEditorWizardPanel }; setWizardPanels(wizardPanels); setPixelSize(475, 465); center(); if ((hasParams || isEmailConfValid) && (isBlockoutDialog == false)) { finishButton.setText(Messages.getString("next")); //$NON-NLS-1$ } else { finishButton.setText(Messages.getString("finish")); //$NON-NLS-1$ } setupExisting(jsJob); wizardDeckPanel.getElement().getParentElement().addClassName("schedule-dialog-content"); wizardDeckPanel.getElement().getParentElement().removeClassName("dialog-content"); //setHeight("100%"); //$NON-NLS-1$ setSize("650px", "450px"); addStyleName("schedule-recurrence-dialog"); }
From source file:org.pentaho.mantle.client.dialogs.scheduling.ScheduleRecurrenceDialog.java
License:Open Source License
private void showScheduleEmailDialog(final JSONObject schedule) { try {/*w w w . j av a 2s . co m*/ final String url = ScheduleHelper.getFullyQualifiedURL() + "api/mantle/isAuthenticated"; //$NON-NLS-1$ RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.GET, url); requestBuilder.setHeader("accept", "text/plain"); //$NON-NLS-1$ //$NON-NLS-2$ requestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT"); requestBuilder.sendRequest(null, new RequestCallback() { @Override public void onError(Request request, Throwable caught) { MantleLoginDialog.performLogin(new AsyncCallback<Boolean>() { @Override public void onFailure(Throwable caught) { } @Override public void onSuccess(Boolean result) { showScheduleEmailDialog(schedule); } }); } @Override public void onResponseReceived(Request request, Response response) { JSONObject scheduleRequest = (JSONObject) JSONParser.parseStrict(schedule.toString()); if (scheduleEmailDialog == null) { scheduleEmailDialog = new ScheduleEmailDialog(ScheduleRecurrenceDialog.this, filePath, scheduleRequest, null, editJob); scheduleEmailDialog.setCallback(callback); } else { scheduleEmailDialog.setJobSchedule(scheduleRequest); } scheduleEmailDialog.setNewSchedule(newSchedule); scheduleEmailDialog.center(); hide(); } }); } catch (RequestException e) { Window.alert(e.getMessage()); } }
From source file:org.pentaho.mantle.client.dialogs.scheduling.ScheduleRecurrenceDialog.java
License:Open Source License
private void showScheduleParamsDialog(final JsJobTrigger trigger, final JSONObject schedule) { try {/* w ww. j a v a 2 s . c o m*/ final String url = ScheduleHelper.getFullyQualifiedURL() + "api/mantle/isAuthenticated"; //$NON-NLS-1$ RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.GET, url); requestBuilder.setHeader("accept", "text/plain"); //$NON-NLS-1$ //$NON-NLS-2$ requestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT"); requestBuilder.sendRequest(null, new RequestCallback() { @Override public void onError(Request request, Throwable caught) { MantleLoginDialog.performLogin(new AsyncCallback<Boolean>() { @Override public void onFailure(Throwable caught) { } @Override public void onSuccess(Boolean result) { showScheduleParamsDialog(trigger, schedule); } }); } @Override public void onResponseReceived(Request request, Response response) { if (scheduleParamsDialog == null) { scheduleParamsDialog = new ScheduleParamsDialog(ScheduleRecurrenceDialog.this, isEmailConfValid, editJob); scheduleParamsDialog.setCallback(callback); } else { scheduleParamsDialog.setJobSchedule(schedule); } scheduleParamsDialog.setNewSchedule(newSchedule); scheduleParamsDialog.center(); hide(); } }); } catch (RequestException e) { Window.alert(e.getMessage()); } }