Package com.google.api.explorer.client.routing

Examples of com.google.api.explorer.client.routing.UrlBuilder


   * URL, given the method name and method definition returned by
   * {@link #getMethodForUrl(ApiService, String)}.
   */
  @VisibleForTesting
  static String createExplorerLink(ApiService service, String url, ApiMethod method) {
    UrlBuilder builder = new UrlBuilder();

    // Add the basic information to the
    builder.addRootNavigationItem(RootNavigationItem.ALL_VERSIONS)
        .addService(service.getName(), service.getVersion())
        .addMethodName(method.getId());

    // Calculate the params from the path template and url.
    URLFragment parsed = URLFragment.parseFragment(url);
    Multimap<String, String> params = HashMultimap.create();
    String pathTemplate = method.getPath();
    if (pathTemplate.contains("{")) {
      String urlPath = parsed.getPath().replaceFirst(Config.getBaseUrl() + service.basePath(), "");
      String[] templateSections = pathTemplate.split("/");
      String[] urlSections = urlPath.split("/");
      for (int i = 0; i < templateSections.length; i++) {
        if (templateSections[i].contains("{")) {
          String paramName = templateSections[i].substring(1, templateSections[i].length() - 1);
          params.put(paramName, urlSections[i]);
        }
      }
    }

    // Apply the params.
    String fullUrl = builder.addQueryParams(params).toString();

    // Check if the url had query parameters to add.
    if (!parsed.getQueryString().isEmpty()) {
      fullUrl = fullUrl + parsed.getQueryString();
    }
View Full Code Here


      methodItem.addStyleName(style.selectableDropDownMenuItem());
      methodItem.setText(method.getId());
      menuContents.add(methodItem);

      // When clicked, Navigate to the menu item.
      UrlBuilder builder = new UrlBuilder();
      String newUrl = builder
          .addRootNavigationItem(RootNavigationItem.ALL_VERSIONS)
          .addService(service.getName(), service.getVersion())
          .addMethodName(method.getId())
          .addQueryParams(resourceParams)
          .toString();
View Full Code Here

TOP

Related Classes of com.google.api.explorer.client.routing.UrlBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.