List of usage examples for org.springframework.web.util UriComponentsBuilder fromHttpUrl
public static UriComponentsBuilder fromHttpUrl(String httpUrl)
From source file:com.jvoid.core.controller.HomeController.java
@RequestMapping("/order") public @ResponseBody String orderProductNowById(@RequestParam("cartId") String cartId, @RequestParam("prodId") String productId) { RestTemplate restTemplate = new RestTemplate(); HttpHeaders headers = new HttpHeaders(); headers.set("Accept", MediaType.APPLICATION_JSON_VALUE); JSONObject jsonObj = new JSONObject(); try {//from w w w . j a va 2 s. c o m jsonObj.put("cartId", Integer.parseInt(cartId)); jsonObj.put("productId", Integer.parseInt(productId)); jsonObj.put("attributeId", 1); jsonObj.put("quantity", 1); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } System.out.println("param jsonObj=>" + jsonObj.toString()); UriComponentsBuilder builder = UriComponentsBuilder .fromHttpUrl(ServerUris.QUOTE_SERVER_URI + URIConstants.ADD_PRODUCT_TO_CART) .queryParam("params", jsonObj); HttpEntity<?> entity = new HttpEntity<>(headers); HttpEntity<String> returnString = restTemplate.exchange(builder.build().toUri(), HttpMethod.GET, entity, String.class); return returnString.getBody(); }
From source file:com.orange.ngsi2.client.Ngsi2Client.java
/** * Create a new registration/*from w w w . jav a 2 s . c om*/ * @param registration the Registration to add * @return the listener to notify of completion */ public ListenableFuture<Void> addRegistration(Registration registration) { return adapt(request(HttpMethod.POST, UriComponentsBuilder.fromHttpUrl(baseURL).path("v2/registrations").toUriString(), registration, Void.class)); }
From source file:io.pivotal.cla.service.github.MylynGitHubApi.java
@Override @SneakyThrows//w w w.jav a 2 s.co m public List<PullRequestStatus> createUpdatePullRequestStatuses(MigratePullRequestStatusRequest request) { GitHubClient client = createClient(request.getAccessToken()); PullRequestService pullRequestService = new PullRequestService(client); String commitStatusUrl = request.getCommitStatusUrl(); String accessToken = request.getAccessToken(); List<PullRequestStatus> results = new ArrayList<>(); for (String repositoryId : request.getRepositoryIds()) { RepositoryId repository = RepositoryId.createFromId(repositoryId); List<PullRequest> repositoryPullRequests = pullRequestService.getPullRequests(repository, "open"); for (PullRequest pullRequest : repositoryPullRequests) { PullRequestStatus status = new PullRequestStatus(); String sha = pullRequest.getHead().getSha(); String syncUrl = UriComponentsBuilder.fromHttpUrl(request.getBaseSyncUrl()) .queryParam("repositoryId", repositoryId) .queryParam("pullRequestId", pullRequest.getNumber()).build().toUriString(); status.setPullRequestId(pullRequest.getNumber()); status.setRepoId(repositoryId); status.setSha(sha); status.setGitHubUsername(pullRequest.getUser().getLogin()); status.setUrl(commitStatusUrl); status.setAccessToken(accessToken); status.setFaqUrl(request.getFaqUrl()); status.setSyncUrl(syncUrl); status.setPullRequestState(pullRequest.getState()); results.add(status); } } return results; }
From source file:org.starfishrespect.myconsumption.android.ui.AddSensorActivity.java
private boolean edit() { ObjectMapper mapper = new ObjectMapper(); RestTemplate template = new RestTemplate(); HttpHeaders httpHeaders = CryptoUtils.createHeadersCurrentUser(); ResponseEntity<String> responseEnt; template.getMessageConverters().add(new FormHttpMessageConverter()); template.getMessageConverters().add(new StringHttpMessageConverter()); try {//www . jav a 2s . c o m UriComponentsBuilder builder = UriComponentsBuilder .fromHttpUrl(SingleInstance.getServerUrl() + "sensors/" + editSensor.getSensorId()) .queryParam("name", editTextSensorName.getText().toString()) .queryParam("type", selectedSensorType) .queryParam("settings", mapper.writeValueAsString(sensorView.getSensorSettings())); responseEnt = template.exchange(builder.build().encode().toUri(), HttpMethod.POST, new HttpEntity<>(httpHeaders), String.class); String result = responseEnt.getBody(); Log.d(TAG, result); SimpleResponseDTO response = mapper.readValue(result, SimpleResponseDTO.class); if (response.getStatus() == 0) { return true; } } catch (HttpClientErrorException e) { e.printStackTrace(); return false; } catch (IOException e) { e.printStackTrace(); return false; } return false; }
From source file:com.orange.ngsi2.client.Ngsi2Client.java
/** * Retrieve the registration by registration ID * @param registrationId the registration ID * @return registration//from w ww. j a v a 2 s.c om */ public ListenableFuture<Registration> getRegistration(String registrationId) { UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(baseURL); builder.path("v2/registrations/{registrationId}"); return adapt(request(HttpMethod.GET, builder.buildAndExpand(registrationId).toUriString(), null, Registration.class)); }
From source file:com.jvoid.core.controller.HomeController.java
@RequestMapping("/cart") public @ResponseBody String getCartById(@RequestParam("cartId") String cartId) { RestTemplate restTemplate = new RestTemplate(); HttpHeaders headers = new HttpHeaders(); headers.set("Accept", MediaType.APPLICATION_JSON_VALUE); JSONObject jsonObj = new JSONObject(); try {/* w w w .j a va 2 s.c o m*/ jsonObj.put("cartId", Integer.parseInt(cartId)); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } System.out.println("param jsonObj=>" + jsonObj.toString()); UriComponentsBuilder builder = UriComponentsBuilder .fromHttpUrl(ServerUris.QUOTE_SERVER_URI + URIConstants.GET_CART).queryParam("params", jsonObj); HttpEntity<?> entity = new HttpEntity<>(headers); HttpEntity<String> returnString = restTemplate.exchange(builder.build().toUri(), HttpMethod.GET, entity, String.class); return returnString.getBody(); }
From source file:com.orange.ngsi2.client.Ngsi2Client.java
/** * Update the registration by registration ID * @param registrationId the registration ID * @return/*from w w w . j a v a2s . c o m*/ */ public ListenableFuture<Void> updateRegistration(String registrationId, Registration registration) { UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(baseURL); builder.path("v2/registrations/{registrationId}"); return adapt(request(HttpMethod.PATCH, builder.buildAndExpand(registrationId).toUriString(), registration, Void.class)); }
From source file:com.orange.ngsi2.client.Ngsi2Client.java
/** * Delete the registration by registration ID * @param registrationId the registration ID * @return//from w ww . j av a 2s . c om */ public ListenableFuture<Void> deleteRegistration(String registrationId) { UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(baseURL); builder.path("v2/registrations/{registrationId}"); return adapt( request(HttpMethod.DELETE, builder.buildAndExpand(registrationId).toUriString(), null, Void.class)); }
From source file:com.jvoid.core.controller.HomeController.java
@RequestMapping("/remove-cart") public @ResponseBody String removeItemsFromCartById(@RequestParam("cartId") String cartId, @RequestParam("prodId") String prodId) { RestTemplate restTemplate = new RestTemplate(); HttpHeaders headers = new HttpHeaders(); headers.set("Accept", MediaType.APPLICATION_JSON_VALUE); JSONObject jsonObj = new JSONObject(); try {// w ww. j a v a2s. co m jsonObj.put("cartId", Integer.parseInt(cartId)); jsonObj.put("productId", Integer.parseInt(prodId)); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } System.out.println("param jsonObj=>" + jsonObj.toString()); UriComponentsBuilder builder = UriComponentsBuilder .fromHttpUrl(ServerUris.QUOTE_SERVER_URI + URIConstants.DELETE_CART).queryParam("params", jsonObj); HttpEntity<?> entity = new HttpEntity<>(headers); HttpEntity<String> returnString = restTemplate.exchange(builder.build().toUri(), HttpMethod.GET, entity, String.class); return returnString.getBody(); }
From source file:com.orange.ngsi2.client.Ngsi2Client.java
/** * Retrieve the list of all Subscriptions present in the system * @param offset an optional offset (0 for none) * @param limit an optional limit (0 for none) * @param count true to return the total number of matching entities * @return a pagined list of Subscriptions *///w ww. jav a2s. c o m public ListenableFuture<Paginated<Subscription>> getSubscriptions(int offset, int limit, boolean count) { UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(baseURL); builder.path("v2/subscriptions"); addPaginationParams(builder, offset, limit); if (count) { addParam(builder, "options", "count"); } return adaptPaginated(request(HttpMethod.GET, builder.toUriString(), null, Subscription[].class), offset, limit); }