List of usage examples for com.google.gwt.http.client UrlBuilder UrlBuilder
UrlBuilder
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 w w w . j ava2 s .c o m*/ return builder; }
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 .ja v a2 s. c o 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));//from www. j a v a 2 s.c om 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 w w w.j a v a 2 s. c o 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//from ww w . j a v a 2s . c om */ 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 w w w .j a v a2 s .com*/ 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:nl.sense_os.commonsense.main.client.viz.panels.table.SensorDataGrid.java
License:Open Source License
private String createUrl(List<ExtSensor> sensors, long startTime, long endTime) { int id = sensors.get(0).getId(); final UrlBuilder urlBuilder = new UrlBuilder().setProtocol(CommonSenseClient.Urls.PROTOCOL) .setHost(CommonSenseClient.Urls.HOST); urlBuilder.setPath(Urls.PATH_SENSORS + "/" + id + "/data.json"); final int alias = sensors.get(0).getAlias(); if (alias != -1) { urlBuilder.setParameter("alias", "" + alias); }/*from www. j a v a2s .c o m*/ urlBuilder.setParameter("start_date", NumberFormat.getFormat("#.000").format(startTime / 1000d)); if (endTime != -1) { urlBuilder.setParameter("end_date", NumberFormat.getFormat("#.000").format(endTime / 1000d)); } // urlBuilder.setParameter("total", "1"); return urlBuilder.buildString(); }
From source file:org.bonitasoft.console.client.model.processes.ProcessDataSourceImpl.java
License:Open Source License
public String buildWebAppURL(BonitaProcess aProcess) { final String theHost = Window.Location.getHost(); final String theProtocol = Window.Location.getProtocol(); return new UrlBuilder().setProtocol(theProtocol).setHost(theHost) .setPath(aProcess.getUUID().getValue() + HOST_PAGE_PATH).buildString(); }
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 w w w. j av a2s .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 v a2s. c om 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(); } } }