List of usage examples for com.google.gwt.http.client UrlBuilder setProtocol
public UrlBuilder setProtocol(String protocol)
From source file:cc.alcina.framework.gwt.client.util.ClientUtils.java
License:Apache License
public static UrlBuilder getBaseUrlBuilder() { UrlBuilder builder = new UrlBuilder(); builder.setProtocol(Window.Location.getProtocol()); builder.setHost(Window.Location.getHostName()); String port = Window.Location.getPort(); if (port != null && port.length() > 0) { builder.setPort(Integer.parseInt(port)); }/*from www .j a v a 2s . c o m*/ return builder; }
From source file:ch.unifr.pai.twice.multipointer.client.ExtendedWebsocketControl.java
License:Apache License
@Override public void start() { if (!isInIFrame()) { initializeCursorList();/*from w ww . jav a2 s .co m*/ if (r != null) r.removeHandler(); r = Window.addResizeHandler(this); UrlBuilder b = Window.Location.createUrlBuilder(); b.setProtocol("ws"); b.setPath("mouseControlXBrowser"); b.setHash(null); String p = Window.Location.getPort(); Integer port; try { port = p != null ? Integer.parseInt(p) : 8080; } catch (NumberFormatException e) { port = 8080; } b.setPort(port + 1); for (String param : Window.Location.getParameterMap().keySet()) { b.removeParameter(param); } websocket = createWebsocket(this, b.buildString()); if (websocket != null) createOnBeforeUnloadHandler(websocket); } }
From source file:com.google.gerrit.client.Gerrit.java
License:Apache License
public static String selfRedirect(String suffix) { // Clean up the path. Users seem to like putting extra slashes into the URL // which can break redirections by misinterpreting at either client or server. String path = Location.getPath(); if (path == null || path.isEmpty()) { path = "/"; } else {//from w ww . j av a2 s . co m while (path.startsWith("//")) { path = path.substring(1); } while (path.endsWith("//")) { path = path.substring(0, path.length() - 1); } if (!path.endsWith("/")) { path = path + "/"; } } if (suffix != null) { while (suffix.startsWith("/")) { suffix = suffix.substring(1); } path += suffix; } UrlBuilder builder = new UrlBuilder(); builder.setProtocol(Location.getProtocol()); builder.setHost(Location.getHost()); String port = Location.getPort(); if (port != null && !port.isEmpty()) { builder.setPort(Integer.parseInt(port)); } builder.setPath(path); return builder.buildString(); }
From source file:com.google.livingstories.client.util.UriParser.java
License:Apache License
public static UrlBuilder parse(String url) { UrlBuilder urlBuilder = new UrlBuilder(); // This utility only needs to support http urls. urlBuilder.setProtocol("http"); urlBuilder.setHost(matchHost(url));// w ww . j ava 2 s. c o m urlBuilder.setPath(matchPath(url)); String queryString = matchQuery(url); if (!queryString.isEmpty()) { for (String params : queryString.split("&")) { // Doesn't work for urls with multiple values on the same key. // But we don't currently need that. String[] pair = params.split("="); urlBuilder.setParameter(pair[0], pair.length > 1 ? pair[1] : ""); } } return urlBuilder; }
From source file:nl.sense_os.commonsense.login.client.login.LoginActivity.java
License:Open Source License
private void goToMainPage() { UrlBuilder builder = new UrlBuilder(); builder.setProtocol(Location.getProtocol()); builder.setHost(Location.getHost()); String path = Location.getPath().contains("login.html") ? Location.getPath().replace("login.html", "index.html") : Location.getPath() + "index.html"; builder.setPath(path);//from ww w. jav a2s . co m for (Entry<String, List<String>> entry : Location.getParameterMap().entrySet()) { if ("session_id".equals(entry.getKey())) { // do not copy the session id parameter } else { builder.setParameter(entry.getKey(), entry.getValue().toArray(new String[0])); } } Location.replace(builder.buildString().replace("127.0.0.1%3A", "127.0.0.1:")); }
From source file:nl.sense_os.commonsense.login.client.LoginEntryPoint.java
License:Open Source License
/** * Redirects the user to the main page//www .j a v a2 s . c o m */ public static void goToMainPage() { UrlBuilder builder = new UrlBuilder(); builder.setProtocol(Location.getProtocol()); builder.setHost(Location.getHost()); String path = Location.getPath().contains("login.html") ? Location.getPath().replace("login.html", "index.html") : Location.getPath() + "index.html"; builder.setPath(path); for (Entry<String, List<String>> entry : Location.getParameterMap().entrySet()) { if ("session_id".equals(entry.getKey()) || "error".equals(entry.getKey())) { // do not copy the session id parameter } else { builder.setParameter(entry.getKey(), entry.getValue().toArray(new String[0])); } } String newLocation = builder.buildString(); // do not mangle the GWT development server parameter newLocation = newLocation.replace("127.0.0.1%3A", "127.0.0.1:"); // relocate Location.replace(newLocation); }
From source file:nl.sense_os.commonsense.login.client.newpassword.NewPasswordActivity.java
License:Open Source License
/** * Removes any URL parameters that are not useful anymore after a new password was set. *//*from www.ja v a 2s .co m*/ private static void cleanUrlParameters() { // clear any session ID to prevent from bouncing back immediately SessionManager.removeSessionId(); UrlBuilder builder = new UrlBuilder(); builder.setProtocol(Location.getProtocol()); builder.setHost(Location.getHost()); builder.setPath(Location.getPath()); for (Entry<String, List<String>> entry : Location.getParameterMap().entrySet()) { if ("session_id".equals(entry.getKey()) || "error".equals(entry.getKey()) || "token".equals(entry.getKey())) { // do not copy the session id, error, or token parameters } else { builder.setParameter(entry.getKey(), entry.getValue().toArray(new String[0])); } } String newLocation = builder.buildString(); // do not mangle the GWT development server parameter newLocation = newLocation.replace("127.0.0.1%3A", "127.0.0.1:"); // relocate Location.replace(newLocation); }
From source file:org.broadleafcommerce.openadmin.client.BLCMain.java
License:Apache License
public static String buildStoreFrontBaseUrl(String path) { String prefix = storeFrontWebAppPrefix; if (prefix.startsWith("/")) { UrlBuilder urlBuilder = new UrlBuilder(); urlBuilder.setHost(com.google.gwt.user.client.Window.Location.getHost()); String port = com.google.gwt.user.client.Window.Location.getPort(); if (port != null && port.length() > 0) { urlBuilder.setPort(Integer.valueOf(port)); }//from ww w . j av a 2 s. c o m urlBuilder.setProtocol(com.google.gwt.user.client.Window.Location.getProtocol()); urlBuilder.setPath(prefix + (path == null ? "" : path)); return urlBuilder.buildString(); } return prefix + (path == null ? "" : path); }
From source file:org.eurekastreams.web.client.ui.pages.master.ConnectEntryPoint.java
License:Apache License
/** * Determines the URL to use to launch the main app. *///from w w w. j a va2 s .com private void determineLaunchPage() { String param = Window.Location.getParameter("_main"); if (param != null && !param.isEmpty()) { mainAppLaunchUrl = param; } else { String path = Window.Location.getPath(); int index = path.lastIndexOf('/'); if (index >= 0 && path.length() > index + 1) { UrlBuilder builder = new UrlBuilder(); builder.setProtocol(Window.Location.getProtocol()); builder.setHost(Window.Location.getHost()); try { builder.setPort(Integer.parseInt(Window.Location.getPort())); } catch (Exception ex) { int makeCheckstyleShutUp = 1; } builder.setPath(path.substring(0, index)); mainAppLaunchUrl = builder.buildString(); } } }
From source file:org.pentaho.mantle.client.ui.tabs.MantleTab.java
License:Open Source License
public void createDeepLink() { if (getContent() 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 ww.j a v a2 s . c o m*/ String startup = ((IFrameTabPanel) getContent()).getUrl(); if (!StringUtils.isEmpty(((IFrameTabPanel) getContent()).getDeepLinkUrl())) { startup = ((IFrameTabPanel) getContent()).getDeepLinkUrl(); } UrlBuilder builder = new UrlBuilder(); builder.setProtocol(Window.Location.getProtocol()); builder.setHost(Window.Location.getHostName()); try { builder.setPort(Integer.parseInt(Window.Location.getPort())); } catch (NumberFormatException e) { builder.setPort(UrlBuilder.PORT_UNSPECIFIED); } builder.setPath(Window.Location.getPath()); //UrlBuilder will encode spaces as '+' which is a valid special character so we replace all spaces with '%20' builder.setParameter("name", getLabelText().replaceAll("\\s", "%20")); //the startup string is already encoded with ':' being replaced with '\t' and then encoded again... builder.setParameter("startup-url", startup); final TextArea urlbox = new TextArea(); //encode any space characters urlbox.setText(builder.buildString()); urlbox.setReadOnly(true); urlbox.setVisibleLines(3); dialogBox.setContent(urlbox); urlbox.setHeight("80px"); urlbox.setWidth("600px"); urlbox.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { urlbox.selectAll(); } }); dialogBox.center(); urlbox.selectAll(); } }