List of usage examples for org.springframework.web.util UriComponentsBuilder toUriString
public String toUriString()
From source file:com.teradata.benchto.driver.presto.PrestoClient.java
private URI buildQueryInfoURI(String queryId) { checkState(!prestoURL.isEmpty());//from w w w.j a va 2s . c o m UriComponentsBuilder uriBuilder = UriComponentsBuilder.fromUriString(prestoURL).pathSegment("v1", "query", queryId); return URI.create(uriBuilder.toUriString()); }
From source file:demo.client.ChartClient.java
public FrictionChart getFrequencyChart(String author, String hashtag) { String path = resourceUri + ResourcePaths.FREQUENCY_PATH; UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(path).queryParam("author", author) .queryParam("hashtag", hashtag); ResponseEntity<FrictionChart> response = restTemplate.getForEntity(builder.toUriString(), FrictionChart.class); return response.getBody(); }
From source file:demo.client.ChartClient.java
public FrictionChart getSeriesChart(String author, String hashtag) { String path = resourceUri + ResourcePaths.SERIES_PATH; UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(path).queryParam("author", author) .queryParam("hashtag", hashtag); ResponseEntity<FrictionChart> response = restTemplate.getForEntity(builder.toUriString(), FrictionChart.class); return response.getBody(); }
From source file:org.awesomeagile.webapp.config.SslRedirectConfig.java
@Bean public TomcatEmbeddedServletContainerFactory tomcatFactory() { return new TomcatEmbeddedServletContainerFactory() { @Override//from ww w.ja va2 s. co m protected TomcatEmbeddedServletContainer getTomcatEmbeddedServletContainer(Tomcat tomcat) { Server server = tomcat.getServer(); Service service = new StandardService(); service.setName("ssl-redirect-service"); Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol"); connector.setPort(sslRedirectPort); service.addConnector(connector); server.addService(service); Engine engine = new StandardEngine(); service.setContainer(engine); Host host = new StandardHost(); host.setName("ssl-redirect-host"); engine.addChild(host); engine.setDefaultHost(host.getName()); Context context = new StandardContext(); context.addLifecycleListener(new Tomcat.FixContextListener()); context.setName("ssl-redirect-context"); context.setPath(""); host.addChild(context); Wrapper wrapper = context.createWrapper(); wrapper.setServlet(new HttpServlet() { @Override public void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { ServletServerHttpRequest r = new ServletServerHttpRequest(req); UriComponentsBuilder b = UriComponentsBuilder.fromHttpRequest(r); b.scheme("https"); b.port(null); res.sendRedirect(b.toUriString()); } }); wrapper.setName("ssl-redirect-servlet"); context.addChild(wrapper); context.addServletMapping("/", wrapper.getName()); return super.getTomcatEmbeddedServletContainer(tomcat); } }; }
From source file:de.appsolve.padelcampus.external.cloudflare.CloudFlareApiClient.java
private String getDnsEntriesUrl(String zoneId, String recordType, String recordName) { UriComponentsBuilder builder = UriComponentsBuilder .fromHttpUrl(CLOUDFLARE_API_URL + "zones/" + zoneId + "/dns_records"); if (!StringUtils.isEmpty(recordType)) { builder.queryParam("type", recordType); }/*www . ja v a2 s . c o m*/ if (!StringUtils.isEmpty(recordName)) { builder.queryParam("name", recordName); } return builder.toUriString(); }
From source file:org.mitre.uma.web.ClaimsCollectionEndpoint.java
@RequestMapping(method = RequestMethod.GET) public String collectClaims(@RequestParam("client_id") String clientId, @RequestParam(value = "redirect_uri", required = false) String redirectUri, @RequestParam("ticket") String ticketValue, @RequestParam(value = "state", required = false) String state, Model m, OIDCAuthenticationToken auth) { ClientDetailsEntity client = clientService.loadClientByClientId(clientId); PermissionTicket ticket = permissionService.getByTicket(ticketValue); if (client == null || ticket == null) { logger.info("Client or ticket not found: " + clientId + " :: " + ticketValue); m.addAttribute(HttpCodeView.CODE, HttpStatus.NOT_FOUND); return HttpCodeView.VIEWNAME; }/* ww w .j av a2 s .co m*/ // we've got a client and ticket, let's attach the claims that we have from the token and userinfo // subject Set<Claim> claimsSupplied = Sets.newHashSet(ticket.getClaimsSupplied()); String issuer = auth.getIssuer(); UserInfo userInfo = auth.getUserInfo(); claimsSupplied.add(mkClaim(issuer, "sub", new JsonPrimitive(auth.getSub()))); if (userInfo.getEmail() != null) { claimsSupplied.add(mkClaim(issuer, "email", new JsonPrimitive(userInfo.getEmail()))); } if (userInfo.getEmailVerified() != null) { claimsSupplied.add(mkClaim(issuer, "email_verified", new JsonPrimitive(userInfo.getEmailVerified()))); } if (userInfo.getPhoneNumber() != null) { claimsSupplied .add(mkClaim(issuer, "phone_number", new JsonPrimitive(auth.getUserInfo().getPhoneNumber()))); } if (userInfo.getPhoneNumberVerified() != null) { claimsSupplied.add(mkClaim(issuer, "phone_number_verified", new JsonPrimitive(auth.getUserInfo().getPhoneNumberVerified()))); } if (userInfo.getPreferredUsername() != null) { claimsSupplied.add(mkClaim(issuer, "preferred_username", new JsonPrimitive(auth.getUserInfo().getPreferredUsername()))); } if (userInfo.getProfile() != null) { claimsSupplied.add(mkClaim(issuer, "profile", new JsonPrimitive(auth.getUserInfo().getProfile()))); } ticket.setClaimsSupplied(claimsSupplied); PermissionTicket updatedTicket = permissionService.updateTicket(ticket); if (Strings.isNullOrEmpty(redirectUri)) { if (client.getClaimsRedirectUris().size() == 1) { redirectUri = client.getClaimsRedirectUris().iterator().next(); // get the first (and only) redirect URI to use here logger.info("No redirect URI passed in, using registered value: " + redirectUri); } else { throw new RedirectMismatchException("Unable to find redirect URI and none passed in."); } } else { if (!client.getClaimsRedirectUris().contains(redirectUri)) { throw new RedirectMismatchException("Claims redirect did not match the registered values."); } } UriComponentsBuilder template = UriComponentsBuilder.fromUriString(redirectUri); template.queryParam("authorization_state", "claims_submitted"); if (!Strings.isNullOrEmpty(state)) { template.queryParam("state", state); } String uriString = template.toUriString(); logger.info("Redirecting to " + uriString); return "redirect:" + uriString; }
From source file:com.teradata.benchto.driver.graphite.GraphiteClient.java
private URI buildLoadMetricsURI(Map<String, String> metrics, long fromEpochSecond, long toEpochSecond) { UriComponentsBuilder uriBuilder = UriComponentsBuilder.fromUriString(graphiteURL).path("/render") .queryParam("format", "json").queryParam("from", fromEpochSecond) .queryParam("until", toEpochSecond); for (Map.Entry<String, String> metric : metrics.entrySet()) { String metricQueryExpr = metric.getValue(); String metricName = metric.getKey(); uriBuilder.queryParam("target", format("alias(%s,'%s')", metricQueryExpr, metricName)); }//from www. j a v a 2s . co m return URI.create(uriBuilder.toUriString()); }
From source file:io.pivotal.github.GithubClient.java
public void deleteRepository() throws IOException { if (!shouldDeleteCreateRepository()) { return;/*from ww w. j a va 2 s . c o m*/ } String slug = getRepositorySlug(); CommitService commitService = new CommitService(client()); try { commitService.getCommits(createRepositoryId()); throw new IllegalStateException("Attempting to delete a repository that has commits. Terminating!"); } catch (RequestException e) { if (e.getStatus() != 404 & e.getStatus() != 409) { throw new IllegalStateException( "Attempting to delete a repository, but it appears the repository may have commits. Terminating!", e); } } UriComponentsBuilder uri = UriComponentsBuilder.fromUriString("https://api.github.com/repos/" + slug) .queryParam("access_token", getAccessToken()); rest.delete(uri.toUriString()); }
From source file:fi.vrk.xroad.catalog.collector.actors.FetchWsdlActor.java
private String buildUri(XRoadServiceIdentifierType service) { assert service.getXRoadInstance() != null; assert service.getMemberClass() != null; assert service.getMemberCode() != null; assert service.getServiceCode() != null; UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(getHost()).path(WSDL_CONTEXT_PATH) .queryParam("xRoadInstance", service.getXRoadInstance()) .queryParam("memberClass", service.getMemberClass()) .queryParam("memberCode", service.getMemberCode()) .queryParam("serviceCode", service.getServiceCode()); if (!Strings.isNullOrEmpty(service.getSubsystemCode())) { builder = builder.queryParam("subsystemCode", service.getSubsystemCode()); }//from w ww . j a v a 2 s . co m if (!Strings.isNullOrEmpty(service.getServiceVersion())) { builder = builder.queryParam("version", service.getServiceVersion()); } return builder.toUriString(); }
From source file:com.orange.ngsi2.client.Ngsi2Client.java
/** * Update, append or delete multiple entities in a single operation * @param bulkUpdateRequest a BulkUpdateRequest with an actionType and a list of entities to update * @return Nothing on success/*from www . j a va2s. co m*/ */ public ListenableFuture<Void> bulkUpdate(BulkUpdateRequest bulkUpdateRequest) { UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(baseURL); builder.path("v2/op/update"); return adapt(request(HttpMethod.POST, builder.toUriString(), bulkUpdateRequest, Void.class)); }