/** * Resolves a path relative to the API context. The returned URI will be of the format * scheme://host[:port][/rootContext]/subPath?query. The scheme and port are pulled from the first endpoint in * the endpoints list. The host to use may be virtual (to be resolved by a load balancer) or calculated in * implementations as round-robin or single-host. Note this is not to be confused with the client-side load * balancing provided by the smart client, which overrides any host set here. * * Note that the query string must already be encoded. This is the only way too allow ampersands (&) as part * of a paremeter value */ public URI resolvePath(String subPath, String rawQuery) { String path = ""; // rootContext should be cleaned by setter if (rootContext != null && rootContext.length() > 0) path += rootContext; // add relative path to context path += subPath; if (path.isEmpty()) path = "/"; try { URI uri = RestUtil.buildUri(protocol.toString().toLowerCase(), resolveHost().getName(), port, path, rawQuery, null); log.debug("raw path & query: " + path + "?" + rawQuery); log.debug("resolved URI: " + uri); return uri; } catch (URISyntaxException e) { throw new RuntimeException("Invalid URI syntax", e); } }