List of usage examples for org.springframework.web.util UriComponentsBuilder fromUriString
public static UriComponentsBuilder fromUriString(String uri)
From source file:com.art4ul.jcoon.context.RestClientContext.java
@Override public URI buildUri() { if (baseUrl == null) { throw new InitializationException("@BaseUrl is not set."); }//from w w w . j a v a 2s .c om UriComponentsBuilder componentsBuilder = UriComponentsBuilder.fromUriString(baseUrl + urlPath); if (httpParams != null) { //if (httpMethod == HttpMethod.GET) { for (String key : httpParams.keySet()) { componentsBuilder.queryParam(key, httpParams.get(key)); } //} } return componentsBuilder.buildAndExpand(uriVariable).toUri(); }
From source file:com.nec.harvest.controller.TanaoroshiController.java
/** * Default mapping without path variables for Sales report screen * /*from w w w. ja v a 2 s.co m*/ * @param request * HttpServletRequest * @param response * HttpServletResponse * @param model * Spring model that can be used to render a view * @return A redirect URL */ @Override @RequestMapping(value = "", method = RequestMethod.GET) public String render(@SessionAttribute(Constants.SESS_ORGANIZATION_CODE) String userOrgCode, @SessionAttribute(Constants.SESS_BUSINESS_DAY) Date businessDay, @PathVariable String proGNo) { if (logger.isDebugEnabled()) { logger.debug("Redering stocktake report..."); } // logger.info("Redering category amount screen with default path..."); // Automatically build a redirect link UriComponents uriComponents = UriComponentsBuilder .fromUriString(Constants.TANAOROSHI_PATH + "/{orgCode}/{monthly}").build(); String businessDate = DateFormatUtil.format(businessDay, DateFormat.DATE_WITHOUT_DAY); URI uri = uriComponents.expand(proGNo, userOrgCode, businessDate).encode().toUri(); logger.info("Redirect to inventory management screen with params in session..."); return "redirect:" + uri.toString(); }
From source file:com.nec.harvest.controller.IdoController.java
/** * Default mapping without path variables for IDO screen * //from w w w. j ava 2 s .c o m * @param userOrgCode * @param businessDay * @param proGNo * @param request * @param response * @param model * @return String redirect Uri */ @Override @RequestMapping(value = "", method = RequestMethod.GET) public String render(@SessionAttribute(Constants.SESS_ORGANIZATION_CODE) String userOrgCode, @SessionAttribute(Constants.SESS_BUSINESS_DAY) Date businessDay, @PathVariable String proGNo) { if (logger.isDebugEnabled()) { logger.debug("Redering ido report without parameters..."); } // Automatically build a redirect link UriComponents uriComponents = UriComponentsBuilder.fromUriString(Constants.IDO_PATH + "/{orgCode}/{month}") .build(); String businessMonth = DateFormatUtil.format(businessDay, DateFormat.DATE_WITHOUT_DAY); URI uri = uriComponents.expand(proGNo, userOrgCode, businessMonth).encode().toUri(); return "redirect:" + uri.toString(); }
From source file:com.nec.harvest.controller.HelpController.java
/** * Default mapping without path variables for Help screen * /*from w w w .j a v a2s . c om*/ * @param userOrgCode * @param businessDay * @param proGNo * @param request * @param response * @param model * @return String redirect Uri */ @Override @RequestMapping(value = "", method = RequestMethod.GET) public String render(@SessionAttribute(Constants.SESS_ORGANIZATION_CODE) String userOrgCode, @SessionAttribute(Constants.SESS_BUSINESS_DAY) Date businessDay, @PathVariable String proGNo) { if (logger.isDebugEnabled()) { logger.debug("Redering help report without parameters..."); } // Automatically build a redirect link UriComponents uriComponents = UriComponentsBuilder.fromUriString(Constants.HELP_PATH + "/{orgCode}/{month}") .build(); String businessMonth = DateFormatUtil.format(businessDay, DateFormat.DATE_WITHOUT_DAY); URI uri = uriComponents.expand(proGNo, userOrgCode, businessMonth).encode().toUri(); return "redirect:" + uri.toString(); }
From source file:com.nec.harvest.controller.GenkinController.java
/** * Default mapping without path variables for Cash management screen * /*from w w w. j av a 2 s . co m*/ * @param request * HttpServletRequest * @param response * HttpServletResponse * @param model * Spring model that can be used to render a view * @return A redirect URL */ @Override @RequestMapping(value = "", method = RequestMethod.GET) public String render(@SessionAttribute(Constants.SESS_ORGANIZATION_CODE) String userOrgCode, @SessionAttribute(Constants.SESS_BUSINESS_DAY) Date businessDay, @PathVariable String proGNo) { logger.info("Redering cash management screen with default path..."); // Automatically build a redirect link UriComponents uriComponents = UriComponentsBuilder .fromUriString(Constants.GENKIN_PATH + "/{orgCode}/{monthly}").build(); String businessDate = DateFormatUtil.format(businessDay, DateFormat.DATE_WITHOUT_DAY); URI uri = uriComponents.expand(proGNo, userOrgCode, businessDate).encode().toUri(); logger.info("Redirect to cash management screen with params in session..."); return "redirect:" + uri.toString(); }
From source file:app.data.parse.WebPageUtil.java
public static String smartUri(String old) { return UriComponentsBuilder.fromUriString(old).replaceQueryParam("utm_source") .replaceQueryParam("utm_medium").replaceQueryParam("utm_campaign").replaceQueryParam("utm_term") .replaceQueryParam("utm_content").replaceQueryParam("hmsr").build().toUriString(); }
From source file:com.nec.harvest.controller.SuisController.java
/** {@inheritDoc} */ @Override/* w ww.j ava 2 s .c o m*/ @RequestMapping(value = "", method = RequestMethod.GET) public String render(@SessionAttribute(Constants.SESS_ORGANIZATION_CODE) String orgCode, @SessionAttribute(Constants.SESS_BUSINESS_DAY) Date businessDay, @PathVariable String proGNo) { if (logger.isDebugEnabled()) { logger.debug("Redering suis report..."); } // ? UriComponents uriComponents = UriComponentsBuilder .fromUriString(Constants.SUIS_PATH + "/{orgCode}/{currentQuarter}").build(); String yearQuater = DateUtil.getCurrentQuarter(businessDay); URI uri = uriComponents.expand(proGNo, orgCode, yearQuater).encode().toUri(); logger.info("Redirect to suis screen with params in session..."); return "redirect:" + uri.toString(); }
From source file:com.nec.harvest.controller.KoteiController.java
/** * Default mapping without path variables for KOTEI screen * /*from www .ja v a 2s .co m*/ * @param userOrgCode * @param businessDay * @param proGNo * @param request * @param response * @param model * @return String redirect Uri */ @Override @RequestMapping(value = "", method = RequestMethod.GET) public String render(@SessionAttribute(Constants.SESS_ORGANIZATION_CODE) String userOrgCode, @SessionAttribute(Constants.SESS_BUSINESS_DAY) Date businessDay, @PathVariable String proGNo) { if (logger.isDebugEnabled()) { logger.debug("Redering kotei report without parameters..."); } // Automatically build a redirect link UriComponents uriComponents = UriComponentsBuilder .fromUriString(Constants.KOTEI_PATH + "/{orgCode}/{month}").build(); String businessMonth = DateFormatUtil.format(businessDay, DateFormat.DATE_WITHOUT_DAY); URI uri = uriComponents.expand(proGNo, userOrgCode, businessMonth).encode().toUri(); return "redirect:" + uri.toString(); }
From source file:net.longfalcon.newsj.service.TraktService.java
/** * call text search web service// w w w. ja v a 2 s . c om * @param name * @param type Possible values: movie , show , episode , person , list . * @return */ protected TraktResult[] searchByName(String name, String type) { try { String traktApiUrl = config.getTraktApiUrl(); String traktAppId = config.getTraktAppId(); HttpHeaders httpHeaders = new HttpHeaders(); httpHeaders.set("Content-type", "application/json"); httpHeaders.set("trakt-api-key", traktAppId); httpHeaders.set("trakt-api-version", "2"); HttpEntity<?> requestEntity = new HttpEntity(httpHeaders); UriComponents uriComponents = UriComponentsBuilder.fromUriString(traktApiUrl + "/search") .queryParam("query", name).queryParam("type", type).build(); ResponseEntity<TraktResult[]> responseEntity = restTemplate.exchange(uriComponents.toUri(), HttpMethod.GET, requestEntity, TraktResult[].class); HttpStatus statusCode = responseEntity.getStatusCode(); if (statusCode.is2xxSuccessful() || statusCode.is3xxRedirection()) { return responseEntity.getBody(); } else { _log.error(String.format("Trakt Search request: \n%s\n failed with HTTP code %s : %s", uriComponents.toString(), statusCode.toString(), statusCode.getReasonPhrase())); return null; } } catch (Exception e) { _log.error(e.toString(), e); } return null; }
From source file:tds.assessment.web.endpoints.AssessmentInfoControllerIntegrationTests.java
@Test public void shouldReturnAssessmentInfoForGrade() throws Exception { final String clientName = "SBAC_PT"; AssessmentInfo info1 = random(AssessmentInfo.class); AssessmentInfo info2 = random(AssessmentInfo.class); final String grade = "3"; when(assessmentInfoService.findAssessmentInfoForGrade(clientName, grade)) .thenReturn(Arrays.asList(info1, info2)); MvcResult result = http//from w w w . j av a 2 s . co m .perform(get(UriComponentsBuilder.fromUriString("/SBAC_PT/assessments").build().toUri()) .param("grade", grade).param("assessmentKeys", info1.getKey()) .param("assessmentKeys", info2.getKey()).contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()).andExpect(jsonPath("[0].key", is(info1.getKey()))) .andExpect(jsonPath("[0].id", is(info1.getId()))) .andExpect(jsonPath("[0].subject", is(info1.getSubject()))) .andExpect(jsonPath("[0].grades", is(info1.getGrades()))) .andExpect(jsonPath("[0].label", is(info1.getLabel()))) .andExpect(jsonPath("[0].languages", is(info1.getLanguages()))) .andExpect(jsonPath("[1].key", is(info2.getKey()))).andExpect(jsonPath("[1].id", is(info2.getId()))) .andExpect(jsonPath("[1].subject", is(info2.getSubject()))) .andExpect(jsonPath("[1].grades", is(info2.getGrades()))) .andExpect(jsonPath("[1].label", is(info2.getLabel()))) .andExpect(jsonPath("[1].languages", is(info2.getLanguages()))).andReturn(); List<AssessmentInfo> parsedAssessments = objectMapper .readValue(result.getResponse().getContentAsByteArray(), new TypeReference<List<AssessmentInfo>>() { }); assertThat(parsedAssessments.get(0)).isEqualTo(info1); assertThat(parsedAssessments.get(1)).isEqualTo(info2); }