List of usage examples for com.google.gwt.http.client URL encodeComponent
@Deprecated public static String encodeComponent(String decodedURLComponent)
From source file:org.pentaho.mantle.client.solutionbrowser.SolutionBrowserPerspective.java
License:Open Source License
public void editFile() { if (filesListPanel.getSelectedFileItem().getName().endsWith(".waqr.xaction")) { //$NON-NLS-1$ String filename = filesListPanel.getSelectedFileItem().getName().substring(0, filesListPanel.getSelectedFileItem().getName().indexOf(".waqr.xaction")) + ".waqr.xreportspec"; //$NON-NLS-1$ //$NON-NLS-2$ String url = "adhoc/waqr.html?solution=" + //$NON-NLS-1$ URL.encodeComponent(filesListPanel.getSelectedFileItem().getSolution()) + "&path=" + //$NON-NLS-1$ URL.encodeComponent(filesListPanel.getSelectedFileItem().getPath()) + "&filename=" + //$NON-NLS-1$ URL.encodeComponent(filename); if (!GWT.isScript()) { url = "http://localhost:8080/pentaho/adhoc/waqr.html?solution=" //$NON-NLS-1$ + filesListPanel.getSelectedFileItem().getSolution() + "&path=" //$NON-NLS-1$ + filesListPanel.getSelectedFileItem().getPath() + "&filename=" //$NON-NLS-1$ + filename;/* w ww . ja va 2 s.c o m*/ } // See if it's already loaded for (int i = 0; i < contentTabPanel.getTabCount(); i++) { Widget w = contentTabPanel.getTab(i).getContent(); if (w instanceof IFrameTabPanel && ((IFrameTabPanel) w).getUrl().endsWith(url)) { // Already up, select and exit contentTabPanel.selectTab(i); return; } } contentTabPanel.showNewURLTab( Messages.getString("editingColon") + filesListPanel.getSelectedFileItem().getLocalizedName(), //$NON-NLS-1$ Messages.getString("editingColon") + filesListPanel.getSelectedFileItem().getLocalizedName(), //$NON-NLS-1$ url, true); // Store representation of file in the frame for reference later when save // is called contentTabPanel.getCurrentFrame().setFileInfo(filesListPanel.getSelectedFileItem()); } else if (filesListPanel.getSelectedFileItem().getName().endsWith(".analysisview.xaction")) { //$NON-NLS-1$ openFile( "/" + filesListPanel.getSelectedFileItem().getSolution() + filesListPanel.getSelectedFileItem().getPath(), filesListPanel.getSelectedFileItem().getName(), filesListPanel.getSelectedFileItem().getLocalizedName(), COMMAND.RUN); } else { // check to see if a plugin supports editing ContentTypePlugin plugin = PluginOptionsHelper .getContentTypePlugin(filesListPanel.getSelectedFileItem().getName()); if (plugin != null && plugin.hasCommand(COMMAND.EDIT)) { // load the editor for this plugin String editUrl = plugin.getCommandUrl(filesListPanel.getSelectedFileItem(), COMMAND.EDIT); // See if it's already loaded for (int i = 0; i < contentTabPanel.getTabCount(); i++) { Widget w = contentTabPanel.getTab(i).getContent(); if (w instanceof IFrameTabPanel && ((IFrameTabPanel) w).getUrl().endsWith(editUrl)) { // Already up, select and exit contentTabPanel.selectTab(i); return; } } if (GWT.isScript()) { contentTabPanel.showNewURLTab( Messages.getString("editingColon") //$NON-NLS-1$ + filesListPanel.getSelectedFileItem().getLocalizedName(), Messages.getString("editingColon") //$NON-NLS-1$ + filesListPanel.getSelectedFileItem().getLocalizedName(), editUrl, true); } else { // we have a URL so open it in a new tab String updateUrl = "/MantleService?passthru=" + editUrl; //$NON-NLS-1$ contentTabPanel.showNewURLTab(filesListPanel.getSelectedFileItem().getLocalizedName(), filesListPanel.getSelectedFileItem().getLocalizedName(), updateUrl, true); } // Store representation of file in the frame for reference later when // save is called contentTabPanel.getCurrentFrame().setFileInfo(filesListPanel.getSelectedFileItem()); } else { MessageDialogBox dialogBox = new MessageDialogBox(Messages.getString("error"), //$NON-NLS-1$ Messages.getString("cannotEditFileType"), //$NON-NLS-1$ true, false, true); dialogBox.center(); } } }
From source file:org.pentaho.mantle.client.solutionbrowser.SolutionBrowserPerspective.java
License:Open Source License
public void executeActionSequence(final FileCommand.COMMAND mode) { // open in content panel AbstractCommand authCmd = new AbstractCommand() { protected void performOperation() { performOperation(false);// w w w .j av a 2 s. c o m } protected void performOperation(boolean feedback) { String url = null; String path = filesListPanel.getSelectedFileItem().getPath(); if (path.startsWith("/")) { //$NON-NLS-1$ path = path.substring(1); } if (GWT.isScript()) { url = "ViewAction?solution=" + //$NON-NLS-1$ URL.encodeComponent(filesListPanel.getSelectedFileItem().getSolution()) + "&path=" + //$NON-NLS-1$ URL.encodeComponent(path) + "&action=" + //$NON-NLS-1$ URL.encodeComponent(filesListPanel.getSelectedFileItem().getName()); String mypath = Window.Location.getPath(); if (!mypath.endsWith("/")) { //$NON-NLS-1$ mypath = mypath.substring(0, mypath.lastIndexOf("/") + 1); //$NON-NLS-1$ } mypath = mypath.replaceAll("/mantle/", "/"); //$NON-NLS-1$ //$NON-NLS-2$ if (!mypath.endsWith("/")) { //$NON-NLS-1$ mypath = "/" + mypath; //$NON-NLS-1$ } url = mypath + url; } else { url = "/MantleService?passthru=ViewAction&solution=" //$NON-NLS-1$ + filesListPanel.getSelectedFileItem().getSolution() + "&path=" + path + "&action=" //$NON-NLS-1$//$NON-NLS-2$ + filesListPanel.getSelectedFileItem().getName() + "&userid=joe&password=password"; //$NON-NLS-1$ } if (mode == FileCommand.COMMAND.BACKGROUND) { MessageDialogBox dialogBox = new MessageDialogBox(Messages.getString("info"), //$NON-NLS-1$ Messages.getString("backgroundExecutionWarning"), //$NON-NLS-1$ true, false, true); dialogBox.center(); url += "&background=true"; //$NON-NLS-1$ RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, url); try { 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) { } }); } catch (RequestException e) { } } else if (mode == FileCommand.COMMAND.NEWWINDOW) { // popup blockers might attack this Window.open(url, "_blank", "menubar=yes,location=no,resizable=yes,scrollbars=yes,status=no"); //$NON-NLS-1$ //$NON-NLS-2$ } else if (mode == FileCommand.COMMAND.SUBSCRIBE) { final String myurl = url + "&subscribepage=yes"; //$NON-NLS-1$ AsyncCallback<Boolean> callback = new AsyncCallback<Boolean>() { public void onFailure(Throwable caught) { MessageDialogBox dialogBox = new MessageDialogBox(Messages.getString("error"), //$NON-NLS-1$ Messages.getString("couldNotGetFileProperties"), false, false, true); //$NON-NLS-1$ dialogBox.center(); } public void onSuccess(Boolean subscribable) { if (subscribable) { contentTabPanel.showNewURLTab( filesListPanel.getSelectedFileItem().getLocalizedName(), filesListPanel.getSelectedFileItem().getLocalizedName(), myurl, true); } else { MessageDialogBox dialogBox = new MessageDialogBox(Messages.getString("info"), //$NON-NLS-1$ Messages.getString("noSchedulePermission"), false, false, true); //$NON-NLS-1$ dialogBox.center(); } } }; MantleServiceCache.getService().hasAccess(filesListPanel.getSelectedFileItem().getSolution(), filesListPanel.getSelectedFileItem().getPath(), filesListPanel.getSelectedFileItem().getName(), 3, callback); } else { contentTabPanel.showNewURLTab(filesListPanel.getSelectedFileItem().getLocalizedName(), filesListPanel.getSelectedFileItem().getLocalizedName(), url, true); } } }; authCmd.execute(); }
From source file:org.pentaho.mantle.client.solutionbrowser.tabs.TabWidget.java
License:Open Source License
public void createDeepLink() { if (tabContent instanceof IFrameTabPanel) { PromptDialogBox dialogBox = new PromptDialogBox(Messages.getString("deepLink"), //$NON-NLS-1$ Messages.getString("ok"), Messages.getString("cancel"), false, //$NON-NLS-1$ //$NON-NLS-2$ true);//from w w w . j a v a 2s. co m String url = Window.Location.getProtocol() + "//" + Window.Location.getHostName() + ":" //$NON-NLS-1$//$NON-NLS-2$ + Window.Location.getPort() + Window.Location.getPath() + "?name=" + textLabel.getText() + "&startup-url="; //$NON-NLS-1$ //$NON-NLS-2$ String startup = ((IFrameTabPanel) tabContent).getUrl(); TextBox urlbox = new TextBox(); urlbox.setText(url + URL.encodeComponent(startup)); urlbox.setVisibleLength(80); dialogBox.setContent(urlbox); dialogBox.center(); } }
From source file:org.pentaho.mantle.login.client.MantleLoginDialog.java
License:Open Source License
public MantleLoginDialog() { super(Messages.getString("login"), Messages.getString("login"), Messages.getString("cancel"), false, true); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ IDialogCallback myCallback = new IDialogCallback() { public void cancelPressed() { }/*from w ww.j a v a2 s .c om*/ @SuppressWarnings("deprecation") public void okPressed() { String path = Window.Location.getPath(); if (!path.endsWith("/")) { //$NON-NLS-1$ path = path.substring(0, path.lastIndexOf("/") + 1); //$NON-NLS-1$ } RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, path + "j_spring_security_check"); //$NON-NLS-1$ builder.setHeader("Content-Type", "application/x-www-form-urlencoded"); //$NON-NLS-1$ //$NON-NLS-2$ builder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT"); RequestCallback callback = new RequestCallback() { public void onError(Request request, Throwable exception) { outerCallback.onFailure(exception); } public void onResponseReceived(Request request, Response response) { try { 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, final Throwable caught) { MessageDialogBox errBox = new MessageDialogBox(Messages.getString("loginError"), //$NON-NLS-1$ Messages.getString("authFailed"), false, false, true); //$NON-NLS-1$ errBox.setCallback(new IDialogCallback() { public void cancelPressed() { } public void okPressed() { outerCallback.onFailure(caught); } }); errBox.show(); } public void onResponseReceived(Request request, Response response) { if ("true".equalsIgnoreCase(response.getText())) { long year = 1000 * 60 * 60 * 24 * 365; // one year into the future Date expirationDate = new Date(System.currentTimeMillis() + year); Cookies.setCookie("loginNewWindowChecked", "" + newWindowChk.getValue(), //$NON-NLS-1$//$NON-NLS-2$ expirationDate); outerCallback.onSuccess(newWindowChk != null && newWindowChk.getValue()); } else { outerCallback.onFailure(new Throwable(Messages.getString("authFailed"))); //$NON-NLS-1$ } } }); } catch (final RequestException e) { MessageDialogBox errBox = new MessageDialogBox(Messages.getString("loginError"), //$NON-NLS-1$ Messages.getString("authFailed"), false, false, true); //$NON-NLS-1$ errBox.setCallback(new IDialogCallback() { public void cancelPressed() { } public void okPressed() { outerCallback.onFailure(e); } }); errBox.show(); } } }; try { String username = userTextBox.getText(); String password = passwordTextBox.getText(); builder.sendRequest("j_username=" + URL.encodeComponent(username) + "&j_password=" + URL.encodeComponent(password), callback); //$NON-NLS-1$ //$NON-NLS-2$ } catch (RequestException e) { e.printStackTrace(); } } }; setCallback(myCallback); super.setStylePrimaryName("pentaho-dialog"); }
From source file:org.pentaho.reporting.platform.plugin.gwt.client.ParameterValues.java
License:Open Source License
public String toURL() { final StringBuffer b = new StringBuffer(); for (final Map.Entry<String, ArrayList<String>> entry : backend.entrySet()) { final String key = URL.encodeComponent(entry.getKey()); final ArrayList<String> list = entry.getValue(); for (final String value : list) { if (value == null) { continue; }// w w w .j a v a 2s. c o m if (b.length() > 0) { b.append("&"); } b.append(key); b.append('='); b.append(URL.encodeComponent(value)); } } return b.toString(); }
From source file:org.sigmah.client.page.login.LoginView.java
License:Open Source License
private void doLogin(final String login, final String password, final Button loginButton, final Image loader) { final String query = "email=" + URL.encodeComponent(login) + "&password=" + URL.encodeComponent(password); final RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.POST, "../Login/service"); requestBuilder.setCallback(new RequestCallback() { @Override//from w w w.j av a 2 s .c o m public void onResponseReceived(Request request, Response response) { if (response.getText().contains("OK")) Window.Location.reload(); else { MessageBox.alert(I18N.CONSTANTS.loginConnectErrorTitle(), I18N.CONSTANTS.loginConnectErrorBadLogin(), null); loginButton.setEnabled(true); loader.getElement().getStyle().setVisibility(Visibility.HIDDEN); } } @Override public void onError(Request request, Throwable exception) { MessageBox.alert(I18N.CONSTANTS.loginConnectErrorTitle(), exception.getMessage(), null); loginButton.setEnabled(true); loader.getElement().getStyle().setVisibility(Visibility.HIDDEN); } }); requestBuilder.setRequestData(query); requestBuilder.setHeader("Content-Type", "application/x-www-form-urlencoded"); loginButton.setEnabled(false); loader.getElement().getStyle().setVisibility(Visibility.VISIBLE); try { requestBuilder.send(); } catch (RequestException ex) { MessageBox.alert(I18N.CONSTANTS.loginConnectErrorTitle(), ex.getMessage(), null); } }
From source file:org.sipfoundry.sipxconfig.userportal.client.UserPhonebookSearch.java
License:Contributor Agreement License
private static void clickToCallRestCall(String number) { Map<Integer, String> errorStatuses = new HashMap<Integer, String>(); errorStatuses.put(CLICK_TO_CALL_ERROR, s_searchConstants.invalidPhoneNumber()); HttpRequestBuilder.doPut("/sipxconfig/rest/my/call/" + URL.encodeComponent(number), null, CONTENT_TYPE, VARIANT, null, errorStatuses); }
From source file:org.waveprotocol.wave.client.clipboard.AnnotationSerializer.java
License:Apache License
private static String escape(String s) { return URL.encodeComponent(s); }
From source file:org.waveprotocol.wave.client.common.scrub.Scrub.java
License:Apache License
/** * Scrub a url if scrubbing is turned on * * Does not scrub urls with leading hashes * * @param url/* w ww.jav a 2 s . c o m*/ * @return The scrubbed version of the url, if it's not already scrubbed */ public static String scrub(String url) { if (enableScrubbing) { if (url.startsWith("#") || url.startsWith(REFERRER_SCRUBBING_URL)) { // NOTE(user): The caller should be responsible for url encoding if // neccessary. There is no XSS risk here as it is a fragment. return url; } else { String x = REFERRER_SCRUBBING_URL + URL.encodeComponent(url); return x; } } else { // If we are not scrubbing the url, then we still need to sanitize it, // to protect against e.g. javascript. String sanitizedUri = EscapeUtils.sanitizeUri(url); return sanitizedUri; } }
From source file:org.waveprotocol.wave.client.gadget.GadgetXmlUtil.java
License:Apache License
/** * Returns initialized XML string builder for the gadget with initial prefs. * * @param url that points to the XML definition of this gadget. * @param stateMap initial preference state map for this gadget. * @return content XML string for the gadget. *///w w w . j a va2 s .co m public static XmlStringBuilder constructXml(String url, StateMap stateMap, String loginName) { return constructXml(url, stateMap != null ? URL.encodeComponent(stateMap.toJson()) : "", loginName); }