List of usage examples for org.springframework.web.util UriComponentsBuilder build
public UriComponents build()
From source file:io.bosh.client.jobs.SpringJobs.java
private final Observable<File> getGzip(Consumer<UriComponentsBuilder> builderCallback) { // For responses that have a Content-Type of application/x-gzip, we need to // decompress them. The RestTemplate and HttpClient don't handle this for // us/*from www . j a va2s . com*/ return createObservable(() -> { UriComponentsBuilder builder = UriComponentsBuilder.fromUri(this.root); builderCallback.accept(builder); URI uri = builder.build().toUri(); return this.restOperations.execute(uri, HttpMethod.GET, null, new ResponseExtractor<File>() { @Override public File extractData(ClientHttpResponse response) throws IOException { return decompress(response.getBody()); } }); }); }
From source file:svc.data.citations.datasources.tyler.TylerCitationDataSource.java
@Override public List<Citation> getByCitationNumberAndDOB(String citationNumber, LocalDate dob) { UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(tylerConfiguration.rootUrl) .queryParam("citationNumber", citationNumber).queryParam("dob", dob.format(dobFormatter)); return performRestTemplateCall(builder.build().encode().toUri()); }
From source file:ca.qhrtech.services.implementations.BGGServiceImpl.java
private URI buildUriForQuery(Game game) { UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(BASE_BGG_URL + END_POINT_SEARCH); builder.queryParam("query", game.getName()); builder.queryParam("type", "boardgame"); return builder.build().encode().toUri(); }
From source file:net.shibboleth.idp.cas.protocol.ServiceTicketResponse.java
public String getRedirectUrl() { final UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(service); if (saml) {/* w ww . j a v a 2s . co m*/ builder.queryParam(SamlParam.SAMLart.name(), ticket); } else { builder.queryParam(ProtocolParam.Ticket.id(), ticket); } return builder.build().toUriString(); }
From source file:info.joseluismartin.gtc.AbstractTileCache.java
/** * Create a parameter map from a query string * @param uri the query string/*from www. j a va 2s .co m*/ * @return a map with parameters */ protected Map<String, String> getParameterMap(String uri) { UriComponentsBuilder b = UriComponentsBuilder.newInstance(); b.query(uri); UriComponents c = b.build(); return c.getQueryParams().toSingleValueMap(); }
From source file:org.awesomeagile.testing.google.FakeGoogleController.java
@ResponseBody @RequestMapping(method = RequestMethod.GET, path = "/oauth2/auth") public ResponseEntity<?> authenticate(@RequestParam("client_id") String clientId, @RequestParam(value = "client_secret", required = false) String clientSecret, @RequestParam("response_type") String responseType, @RequestParam("redirect_uri") String redirectUri, @RequestParam("scope") String scope) { // Validate client_id and client_secret if (!this.clientId.equals(clientId) || (clientSecret != null && !this.clientSecret.equals(clientSecret))) { return ResponseEntity.<String>badRequest().body("Wrong client_id or client_secret!"); }/*from w ww .j a v a 2 s.co m*/ if (!prefixMatches(redirectUri)) { return wrongRedirectUriResponse(); } String code = RandomStringUtils.randomAlphanumeric(64); String token = RandomStringUtils.randomAlphanumeric(64); codeToToken.put(code, new AccessToken(token, scope, "", System.currentTimeMillis() + EXPIRATION_MILLIS)); UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(redirectUri).queryParam(CODE, code); return ResponseEntity.status(HttpStatus.FOUND).header(HttpHeaders.LOCATION, builder.build().toUriString()) .build(); }
From source file:info.joseluismartin.gtc.WmsCache.java
/** * {@inheritDoc}//from w w w . j ava 2s. c o m * @throws IOException */ @Override public InputStream parseResponse(InputStream serverStream, String remoteUri, String localUri) throws IOException { UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(remoteUri); UriComponents remoteComponents = builder.build(); String localUrl = localUri + "/" + getPath(); InputStream is = serverStream; MultiValueMap<String, String> params = remoteComponents.getQueryParams(); if (GET_CAPABILITIES.equals(params.getFirst(REQUEST))) { String response = IOUtils.toString(serverStream); Document doc = XMLUtils.newDocument(response); if (log.isDebugEnabled()) XMLUtils.prettyDocumentToString(doc); // Fix GetMapUrl Element getMapElement = (Element) doc.getElementsByTagName(GET_MAP).item(0); if (getMapElement != null) { if (log.isDebugEnabled()) { log.debug("Found GetMapUrl: " + this.getMapUrl); } NodeList nl = getMapElement.getElementsByTagName(ONLINE_RESOURCE_ELEMENT); if (nl.getLength() > 0) { Element resource = (Element) nl.item(0); if (resource.hasAttributeNS(XLINK_NS, HREF_ATTRIBUTE)) { this.getMapUrl = resource.getAttributeNS(XLINK_NS, HREF_ATTRIBUTE).replace("?", ""); resource.setAttributeNS(XLINK_NS, HREF_ATTRIBUTE, localUrl); } } } // Fix GetFeatureInfoUrl Element getFeatureElement = (Element) doc.getElementsByTagName(GET_FEATURE_INFO).item(0); if (getFeatureElement != null) { if (log.isDebugEnabled()) { log.debug("Found GetFeatureInfoUrl: " + this.getFeatureInfoUrl); } NodeList nl = getFeatureElement.getElementsByTagName(ONLINE_RESOURCE_ELEMENT); if (nl.getLength() > 0) { Element resource = (Element) nl.item(0); if (resource.hasAttributeNS(XLINK_NS, HREF_ATTRIBUTE)) { this.getFeatureInfoUrl = resource.getAttributeNS(XLINK_NS, HREF_ATTRIBUTE).replace("?", ""); resource.setAttributeNS(XLINK_NS, HREF_ATTRIBUTE, localUrl); } } } response = XMLUtils.documentToString(doc); response = response.replaceAll(getServerUrl(), localUrl); // response = "<?xml version='1.0' encoding='UTF-8'>" + response; is = IOUtils.toInputStream(response); } return is; }
From source file:com.orange.clara.cloud.cf.servicebroker.log.infrastructure.SplunkDashboardUrlFactory.java
@Override public String getAppDashboardUrl(String appGuid) { UriComponentsBuilder urlBuilder = UriComponentsBuilder.fromHttpUrl(logServerUrl); urlBuilder.path(SEARCH_PATH);// w w w. j av a 2 s .c o m //uncomment to enable auto pause mode //urlBuilder.queryParam("auto_pause", "true"); urlBuilder.queryParam("q", "search index=\"*\" source=\"tcp:12345\" appname=\"" + appGuid + "\""); return urlBuilder.build().encode().toUriString(); }
From source file:svc.data.citations.datasources.tyler.TylerCitationDataSource.java
@Override public List<Citation> getByLicenseAndDOB(String driversLicenseNumber, String driversLicenseState, LocalDate dob) {//from w w w.j a va2 s . c o m UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(tylerConfiguration.rootUrl) .queryParam("licenseNumber", driversLicenseNumber).queryParam("dob", dob.format(dobFormatter)) .queryParam("licenseState", driversLicenseState); return performRestTemplateCall(builder.build().encode().toUri()); }