List of usage examples for org.springframework.web.util UriComponentsBuilder fromHttpUrl
public static UriComponentsBuilder fromHttpUrl(String httpUrl)
From source file:org.appverse.web.framework.backend.frontfacade.rest.MvcExceptionHandlerTests.java
@Test public void test() throws Exception { // Login first TestLoginInfo loginInfo = login();/*from ww w . ja v a 2s . co m*/ HttpHeaders headers = new HttpHeaders(); headers.set("Cookie", loginInfo.getJsessionid()); HttpEntity<String> entity = new HttpEntity<String>(headers); // Calling protected resource - requires CSRF token UriComponentsBuilder builder = UriComponentsBuilder .fromHttpUrl("http://localhost:" + port + baseApiPath + "/hello") .queryParam(DEFAULT_CSRF_PARAMETER_NAME, loginInfo.getXsrfToken()); ResponseEntity<String> responseEntity = restTemplate.exchange(builder.build().encode().toUri(), HttpMethod.GET, entity, String.class); String data = responseEntity.getBody(); assertEquals("Hello World!", data); assertEquals(HttpStatus.OK, responseEntity.getStatusCode()); }
From source file:com.github.tddts.jet.service.impl.AuthServiceImpl.java
private URI getLoginPageURI(String clientId, String responseType) { return UriComponentsBuilder.fromHttpUrl(loginAuthURL).queryParam("response_type", responseType) .queryParam("redirect_uri", redirectURI).queryParam("realm", realm) .queryParam("client_id", clientId).queryParam("scope", scopes).queryParam("state", state).build() .toUri();//from w w w.j a va 2s.co m }
From source file:fi.helsinki.opintoni.integration.leiki.LeikiRestClient.java
@Override public List<LeikiCategoryHit> searchCategory(String searchTerm, Locale locale) { URI uri = UriComponentsBuilder.fromHttpUrl(baseUrl).path("/focus/api") .queryParam("method", "searchcategories").queryParam("autocomplete", "occurred") .queryParam("lang", locale.getLanguage()).queryParam("text", searchTerm) .queryParam("format", "json").queryParam("max", maxCategoryResults).build().encode().toUri(); return getLeikiCategoryData(uri, new ParameterizedTypeReference<LeikiCategoryResponse<LeikiCategoryHit>>() { });//from w w w. j ava 2 s .c om }
From source file:de.hybris.platform.acceleratorservices.payment.cybersource.strategies.impl.DefaultPaymentFormActionUrlStrategy.java
protected URI getAdjustRequestURI(final String urlStr) { if (urlStr.charAt(0) == '/') { // Relative path final String siteBaseUrl = getSiteBaseUrlResolutionService() .getWebsiteUrlForSite(getBaseSiteService().getCurrentBaseSite(), true, "/"); // Push the site relative path into the URL return UriComponentsBuilder.fromHttpUrl(siteBaseUrl).replacePath(urlStr).build().toUri(); }//from ww w .j a v a2 s .co m return URI.create(urlStr); }
From source file:it.scoppelletti.wui.PromptDialogAction.java
@Override public String execute() { String uri;//from w w w . ja va 2s .c o m UriComponentsBuilder uriBuilder; uri = getViewState().get(PromptDialogAction.VIEWSTATE_ACTIONURL); if (Strings.isNullOrEmpty(uri)) { throw new PropertyNotSetException(toString(), PromptDialogAction.VIEWSTATE_ACTIONURL); } uriBuilder = UriComponentsBuilder.fromHttpUrl(uri); uriBuilder.queryParam("closingDialogId", getViewState().get(ActionBase.VIEWSTATE_VIEWID)); for (Map.Entry<String, String> param : getCallerState().entrySet()) { uriBuilder.queryParam(PromptDialogAction.VIEWSTATE_PREFIX.concat(param.getKey()), param.getValue()); } myActionUrl = uriBuilder.build().toUriString(); myLogger.info("User accepted action {}.", myActionUrl); return Action.SUCCESS; }
From source file:ca.qhrtech.services.implementations.BGGServiceImpl.java
private URI buildUriForLink(long bggId) { UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(BASE_BGG_URL + END_POINT_LINK); builder.queryParam("id", bggId); builder.queryParam("type", "boardgame"); return builder.build().encode().toUri(); }
From source file:it.ms.template.presentation.config.SwaggerConfig.java
@Bean public SwaggerPathProvider getSwaggerPathProvider() { return new SwaggerPathProvider() { @Autowired//from w w w . j a v a 2 s . c o m private ServletContext servletContext; @Override protected String applicationPath() { return getAppRoot().build().toString(); } @Override protected String getDocumentationPath() { return getAppRoot().path(DefaultSwaggerController.DOCUMENTATION_BASE_PATH).build().toString(); } private UriComponentsBuilder getAppRoot() { return UriComponentsBuilder.fromHttpUrl(environment.getProperty(SWAGGER_URL)) .path(servletContext.getContextPath()); } }; }
From source file:com.gemstone.gemfire.rest.internal.web.swagger.config.RestApiPathProvider.java
@Override public String getAppBasePath() { return UriComponentsBuilder.fromHttpUrl(docsLocation).path(servletContext.getContextPath()).build() .toString(); }
From source file:com.greglturnquist.spring.social.ecobee.api.impl.ThermostatTemplate.java
@Override public List<Thermostat> getAllThermostats() { try {/* ww w . j ava 2s. c o m*/ final Selection selection = Selection.allThermostats(); selection.getSelection().setIncludeRuntime(true); selection.getSelection().setIncludeSettings(true); selection.getSelection().setIncludeSensors(true); final String selectionStr = this.jsonMessageConverter.getObjectMapper().writeValueAsString(selection); URI uri = UriComponentsBuilder.fromHttpUrl(buildUri("/thermostat")).queryParam("json", selectionStr) .build().toUri(); return this.restTemplate.getForObject(uri, Thermostats.class).getThermostats(); } catch (Exception e) { throw new RuntimeException(e); } }
From source file:com.rsa.redchallenge.standaloneapp.utils.RestInteractor.java
/** * Helper function to create the URL to be called * * @param params parameter for the call * @param restPath path of the interface in the REST server to be called * @return URL to be called/*w w w .j a v a2 s .c o m*/ */ private static String populatePath(Map<String, Object> params, String restPath) { String uri = null; if (params != null && !params.isEmpty()) { String url = restPath; UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(url); for (Map.Entry<String, Object> param : params.entrySet()) builder.queryParam(param.getKey(), param.getValue()); uri = builder.build().toUriString(); } else { uri = restPath; } return uri; }