code: private String extractQueryParam(HttpServletRequest request, Map<String, String> restParams) {
          String query = request.getQueryString();
          if (Utils.isEmpty(query)) {
              return "";
          }
          StringBuilder buffer = new StringBuilder(query);
          
          // Split query component into decoded, &-separate components.
          String[] parts = Utils.splitURIQuery(buffer.toString());
          List<Pair<String, String>> unusedList = new ArrayList<Pair<String,String>>();
          boolean bRewrite = false;
          for (String part : parts) {
              Pair<String, String> param = extractParam(part);
              switch (param.firstItemInPair.toLowerCase()) {
              case "api":
                  bRewrite = true;
                  restParams.put("api", param.secondItemInPair);
                  break;
              case "format":
                  bRewrite = true;
                  if (param.secondItemInPair.equalsIgnoreCase("xml")) {
                      restParams.put("format", "text/xml");
                  } else if (param.secondItemInPair.equalsIgnoreCase("json")) {
                      restParams.put("format", "application/json");
                  }
                  break;
              case "tenant":
                  bRewrite = true;
                  restParams.put("tenant", param.secondItemInPair);
                  break;
              default:
                  unusedList.add(param);
              }
          }
          
          // If we extracted any fixed params, rewrite the query parameter.
          if (bRewrite) {
              buffer.setLength(0);
              for (Pair<String, String> pair : unusedList) {
                  if (buffer.length() > 0) {
                      buffer.append("&");
                  }
                  buffer.append(Utils.urlEncode(pair.firstItemInPair));
                  if (pair.secondItemInPair != null) {
                      buffer.append("=");
                      buffer.append(Utils.urlEncode(pair.secondItemInPair));
                  }
              }
          }
          return buffer.toString();
      }
docs: "format=y", and "tenant=z", if present, to rest parameters.