public static String urlWithQuery(String oldUrl, String paramName, String paramValue) throws URISyntaxException { URIBuilder uriBuilder = new URIBuilder(oldUrl); uriBuilder.addParameter(paramName, paramValue); return uriBuilder.toString(); }
/** * Method to generate url for search using URIBuilder * @return URL in string format */ protected String prepareSearchUrl(String type) { URIBuilder url = null; try { url = new URIBuilder(this.baseUrl + this.query); } catch (URISyntaxException e) { DAO.log("Invalid Url: baseUrl = " + this.baseUrl + ", mid-URL = " + midUrl + "query = " + this.query + "type = " + type); return ""; } return url.toString(); }
/** * Method to generate url for search using URIBuilder * @return URL in string format */ protected String prepareSearchUrl(String type) { URIBuilder url = null; String midUrl = "search/"; try { switch(type) { case "all": case "user": midUrl = ""; url = new URIBuilder(this.baseUrl + midUrl + this.query); break; // Add more types default: url = new URIBuilder(""); break; } } catch (URISyntaxException e) { DAO.log("Invalid Url: baseUrl = " + this.baseUrl + ", mid-URL = " + midUrl + "query = " + this.query + "type = " + type); return ""; } return url.toString(); }
public String sslServerUrl(String sslPort) { String serverUrl = serverUrl(); try { // backward compatibility, since the agent.jar requires an ssl url, but the old bootstrapper does not have one. URIBuilder url = new URIBuilder(serverUrl); if (url.getScheme().equals("http")) { url.setPort(Integer.valueOf(sslPort)); url.setScheme("https"); } return url.toString(); } catch (URISyntaxException e) { throw bomb(e); } } }
protected String prepareSearchUrl(String type) { URIBuilder url = null; String midUrl = "search/"; try { switch (type) { case "search": midUrl = "search/"; url = new URIBuilder(this.baseUrl + midUrl); url.addParameter("search_query", this.query); break; case "video": midUrl = "watch/"; url = new URIBuilder(this.baseUrl + midUrl); url.addParameter("v", this.query); break; case "user": midUrl = "channel/"; url = new URIBuilder(this.baseUrl + midUrl + this.query); break; default: url = new URIBuilder(""); break; } } catch (URISyntaxException e) { DAO.log("Invalid Url: baseUrl = " + this.baseUrl + ", mid-URL = " + midUrl + "query = " + this.query + "type = " + type); return ""; } return url.toString(); }
protected String prepareSearchUrl(String type) { URIBuilder url = null; String midUrl = "search/"; try { switch(type) { case "user": midUrl = "profile/"; url = new URIBuilder(this.baseUrl + midUrl + this.query); break; case "question": url = new URIBuilder(this.baseUrl + midUrl); url.addParameter("q", this.query); url.addParameter("type", "question"); break; case "answer": url = new URIBuilder(this.baseUrl + midUrl); url.addParameter("q", this.query); url.addParameter("type", "answer"); break; default: url = new URIBuilder(""); break; } } catch (URISyntaxException e) { DAO.log("Invalid Url: baseUrl = " + this.baseUrl + ", mid-URL = " + midUrl + "query = " + this.query + "type = " + type); } return url.toString(); }
logger.info("Loading: " + builder.toString()); String webfingerResponse = restTemplate.getForObject(builder.build(), String.class);
uriBuilder.addParameter("error", "access_denied"); uriBuilder.addParameter("error_description", exception.getMessage()); redirectTo = uriBuilder.toString();
+ ", query = " + this.query + ", type = " + type); return url.toString();
response.sendRedirect(uriBuilder.toString()); return;
return "redirect:" + uriBuilder.toString();
private static void setLogLevel(final TargetInfo targetInfo, String logName, String level) throws IOException { URIBuilder uriBuilder = new URIBuilder(); uriBuilder.setScheme("http"); uriBuilder.setHost(targetInfo.getHost()); uriBuilder.setPort(targetInfo.getPort()); uriBuilder.setPath(Constants.REST_API_PREFIX + "/" + targetInfo.getRole() + "/" + LOG_LEVEL); uriBuilder.addParameter(LOG_NAME_OPTION_NAME, logName); if (level != null) { uriBuilder.addParameter(LEVEL_OPTION_NAME, level); } HttpUtils.post(uriBuilder.toString(), 5000, new HttpUtils.IProcessInputStream() { @Override public void process(InputStream inputStream) throws IOException { ObjectMapper mapper = new ObjectMapper(); LogInfo logInfo = mapper.readValue(inputStream, LogInfo.class); System.out.println(targetInfo.toString() + logInfo.toString()); } }); }
userInfoString = restTemplate.getForObject(builder.toString(), String.class);
/** * Connect DB without specified database */ private Connection openWithoutDB(int timeout) { String jdbcUrl = this.config.get(MysqlOptions.JDBC_URL); String url = new URIBuilder().setPath(jdbcUrl) .setParameter("socketTimeout", String.valueOf(timeout)) .toString(); try { return connect(url); } catch (SQLException e) { throw new BackendException("Failed to access %s, " + "please ensure it is ok", jdbcUrl); } }
/** * Connect DB with specified database */ private Connection open(boolean autoReconnect) throws SQLException { String url = this.config.get(MysqlOptions.JDBC_URL); if (url.endsWith("/")) { url = String.format("%s%s", url, this.database); } else { url = String.format("%s/%s", url, this.database); } int maxTimes = this.config.get(MysqlOptions.JDBC_RECONNECT_MAX_TIMES); int interval = this.config.get(MysqlOptions.JDBC_RECONNECT_INTERVAL); URIBuilder uriBuilder = new URIBuilder(); uriBuilder.setPath(url) .setParameter("rewriteBatchedStatements", "true") .setParameter("useServerPrepStmts", "false") .setParameter("autoReconnect", String.valueOf(autoReconnect)) .setParameter("maxReconnects", String.valueOf(maxTimes)) .setParameter("initialTimeout", String.valueOf(interval)); return this.connect(uriBuilder.toString()); }
uri.setParameter("period", String.valueOf((int) (config.getTimeStepSizeInMillis() / 1000))); return uri.toString();
public String getBaseUrl() { return buildBaseUri() .map(b -> b.toString()) .orElse(null); }
protected String buildUriFromRepositoryName(String gitUriParam, String gitServiceUrl) { try { URIBuilder gitUriBuilder = new URIBuilder(gitServiceUrl); gitUriBuilder.setPath(PATH_SEPARATOR + gitUriParam); return gitUriBuilder.toString(); } catch (URISyntaxException e) { throw new SLException(e, Messages.ERROR_PROCESSING_GIT_URI); } }
@Override public String apply(HttpRequest request) { try { return new URIBuilder(request.getUrl()).toString(); } catch (URISyntaxException e) { throw new UnirestException(e); } }
@JsonIgnore public String getAuthBaseUrl() { return buildBaseUri() .get() .setUserInfo(getUsername(), getPassword()) .toString(); }