List of usage examples for org.springframework.http HttpMethod POST
HttpMethod POST
To view the source code for org.springframework.http HttpMethod POST.
Click Source Link
From source file:eu.freme.broker.eservices.FremeNER.java
@RequestMapping(value = "/e-entity/freme-ner/datasets", method = { RequestMethod.POST }) public ResponseEntity<String> createDataset( @RequestHeader(value = "Accept", required = false) String acceptHeader, @RequestHeader(value = "Content-Type", required = false) String contentTypeHeader, @RequestParam(value = "name", required = true) String name, @RequestParam(value = "description", required = true) String description, @RequestParam(value = "language", required = false) String language, //@RequestParam(value = "informat", required = false) String informat, //@RequestParam(value = "f", required = false) String f, @RequestParam(value = "endpoint", required = false) String endpoint, @RequestParam(value = "sparql", required = false) String sparql, @RequestParam Map<String, String> allParams, @RequestBody(required = false) String postBody) { try {// w w w .j a v a 2s .co m if (language != null) { if (!SUPPORTED_LANGUAGES.contains(language)) { // The language specified with the langauge parameter is not supported. throw new eu.freme.broker.exception.BadRequestException("Unsupported language."); } } // first check if user wants to submit data via SPARQL if (endpoint != null && sparql == null) { // endpoint specified, but not sparql => throw exception throw new eu.freme.broker.exception.BadRequestException( "SPARQL endpoint was specified but not a SPARQL query."); } NIFParameterSet nifParameters = this.normalizeNif(postBody, acceptHeader, contentTypeHeader, allParams, true); String format = null; switch (nifParameters.getInformat()) { case TURTLE: format = "TTL"; break; case JSON_LD: format = "JSON-LD"; break; case RDF_XML: format = "RDF/XML"; break; case N_TRIPLES: format = "N-TRIPLES"; break; case N3: format = "N3"; break; } if (endpoint != null) { // fed via SPARQL endpoint return callBackend( fremeNerEndpoint + "/datasets?format=" + format + "&name=" + name + "&description=" + URLEncoder.encode(description, "UTF-8") + "&language=" + language + "&endpoint=" + endpoint + "&sparql=" + URLEncoder.encode(sparql, "UTF-8"), HttpMethod.POST, null); } else { // datasets is sent if (language != null) { return callBackend( fremeNerEndpoint + "/datasets?format=" + format + "&name=" + name + "&description=" + URLEncoder.encode(description, "UTF-8") + "&language=" + language, HttpMethod.POST, nifParameters.getInput()); } else { return callBackend( fremeNerEndpoint + "/datasets?format=" + format + "&name=" + name + "&description=" + URLEncoder.encode(description, "UTF-8"), HttpMethod.POST, nifParameters.getInput()); } } } catch (Exception e) { logger.error(e.getMessage(), e); throw new eu.freme.broker.exception.BadRequestException(e.getMessage()); } }
From source file:org.trustedanalytics.servicebroker.gearpump.service.CloudFoundryService.java
private String getUIAppUrl(String uiServiceInstanceGuid) throws IOException { LOGGER.info("Getting UI App URL using create service key function"); String body = String.format(CREATE_SERVICE_KEY_BODY_TEMPLATE, uiServiceInstanceGuid); ResponseEntity<String> response = execute(POST_CREATE_SERVICE_KEY_URL, HttpMethod.POST, body, cfApiEndpoint);//from w ww. j a va 2 s . c o m String uiAppUrl = cfCaller.getValueFromJson(response.getBody(), APP_URL); String serviceKeyGuid = cfCaller.getValueFromJson(response.getBody(), METADATA_GUID); LOGGER.info("Deleting service key"); execute(DELETE_SERVICE_KEY_URL, HttpMethod.DELETE, "", cfApiEndpoint, serviceKeyGuid); LOGGER.debug("UI App url '{}'", uiAppUrl); return uiAppUrl; }
From source file:com.grizzly.rest.GenericRestCall.java
/** * Post call. Sends T in J form to retrieve a X result. *//*from ww w. ja va2 s.c o m*/ public void doPost() { try { HttpEntity<?> requestEntity; if (!bodyless) { requestEntity = new HttpEntity<Object>(entity, requestHeaders); } else { requestEntity = new HttpEntity<Object>(requestHeaders); } List<HttpMessageConverter<?>> messageConverters = new ArrayList<HttpMessageConverter<?>>(); messageConverters.add(new MappingJackson2HttpMessageConverter()); restTemplate.setMessageConverters(messageConverters); try { if (jsonResponseEntityClass.getCanonicalName().equalsIgnoreCase(Void.class.getCanonicalName())) { ResponseEntity response = restTemplate.exchange(url, HttpMethod.POST, requestEntity, Void.class); result = this.processResponseWithouthData(response); } else { ResponseEntity<X> response = restTemplate.exchange(url, HttpMethod.POST, requestEntity, jsonResponseEntityClass); if (!cachedFileName.isEmpty() && !cachedFileName.equalsIgnoreCase("")) { File f = new File(getCachedFileName()); if (f.exists()) { getFromSolidCache(); result = true; } else { result = this.processResponseWithData(response); } } else { result = this.processResponseWithData(response); } } } catch (Exception e) { failure = e; //e.printStackTrace(); this.result = false; } } catch (Exception e) { failure = e; //e.printStackTrace(); this.result = false; } }
From source file:com.formkiq.web.AbstractIntegrationTest.java
/** * Deletes system property./*from w w w .j a va2 s. c om*/ * @param token {@link String} * @param key {@link String} */ protected void deleteProperty(final String token, final String key) { String url = getDefaultHostAndPort() + API_SYSTEM_PROPERTIES_DELETE + "?access_token=" + token + "&key=" + key; ResponseEntity<String> entity = exchangeRest(HttpMethod.POST, url); assertEquals(SC_OK, entity.getStatusCode().value()); }
From source file:com.logsniffer.event.h2.H2SnifferPersistenceTest.java
/** * Reported by https://github.com/logsniffer/logsniffer/issues/78 *//*w ww. j av a 2s .co m*/ @Test @DirtiesContext public void testDeserializationOfPublishersWithRawJsonData() { final HttpPublisher publisher = new HttpPublisher(); publisher.setMethod(HttpMethod.POST); publisher.setUrl("http://localhost"); publisher.setBody( "{\"channel\":\"#test\",\"username\":\"webhookbot\",\"text\":\"This is posted to #test and comes from a bot named webhookbot.\",\"icon_emoji\":\":ghost:\"}"); final Sniffer s1 = createTestSniffer(); s1.setPublishers(Collections.singletonList((Publisher) publisher)); final long sid = snifferPersistence.createSniffer(s1); final Sniffer test = snifferPersistence.getSniffer(sid); Assert.assertNotNull(test); Assert.assertNotNull(test.getPublishers().get(0) instanceof HttpPublisher); }
From source file:com.projectx.mvc.servicehandler.quickregister.QuickRegisterHandler.java
@Override public AuthenticationDetailsDTO getAuthenticationDetailsByCustomerIdType(Long customerId, Integer customerType) throws AuthenticationDetailsNotFoundException { CustomerIdTypeDTO customerIdDTO = new CustomerIdTypeDTO(customerId, customerType); HttpEntity<CustomerIdTypeDTO> entity = new HttpEntity<CustomerIdTypeDTO>(customerIdDTO); ResponseEntity<AuthenticationDetailsDTO> result = restTemplate.exchange( env.getProperty("rest.host") + "/customer/quickregister/getAuthenticationDetailsById", HttpMethod.POST, entity, AuthenticationDetailsDTO.class); if (result.getStatusCode() == HttpStatus.FOUND) return result.getBody(); else/*from w w w .j a v a 2s . c o m*/ throw new AuthenticationDetailsNotFoundException(); }
From source file:org.starfishrespect.myconsumption.android.ui.AddSensorActivity.java
private boolean create() { DatabaseHelper db = new DatabaseHelper(this); String user = null;/* www . ja v a 2 s . c o m*/ KeyValueData userJson = db.getValueForKey("user"); ObjectMapper mapper = new ObjectMapper(); if (userJson != null) { try { user = mapper.readValue(userJson.getValue(), UserData.class).getName(); } catch (IOException e) { return false; } } if (user == null) { return false; } RestTemplate template = new RestTemplate(); HttpHeaders httpHeaders = CryptoUtils.createHeadersCurrentUser(); ResponseEntity<String> responseEnt; template.getMessageConverters().add(new FormHttpMessageConverter()); template.getMessageConverters().add(new StringHttpMessageConverter()); try { UriComponentsBuilder builder = UriComponentsBuilder .fromHttpUrl(SingleInstance.getServerUrl() + "sensors/") .queryParam("name", editTextSensorName.getText().toString()) .queryParam("type", selectedSensorType).queryParam("user", user) .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.projectx.mvc.servicehandler.quickregister.QuickRegisterHandler.java
@Override public AuthenticationDetailsDTO verifyEmailLoginDetails(VerifyEmailLoginDetails emailLoginDetails) throws AuthenticationDetailsNotFoundException { HttpEntity<VerifyEmailLoginDetails> entity = new HttpEntity<VerifyEmailLoginDetails>(emailLoginDetails); ResponseEntity<AuthenticationDetailsDTO> result = restTemplate.exchange( env.getProperty("rest.host") + "/customer/quickregister/verifyLoginDefaultEmailPassword", HttpMethod.POST, entity, AuthenticationDetailsDTO.class); if (result.getStatusCode() == HttpStatus.OK) return result.getBody(); else// w ww.j ava 2s . c o m throw new AuthenticationDetailsNotFoundException(); }
From source file:com.orange.ngsi2.client.Ngsi2Client.java
/** * Create a new registration/*from w w w . ja v a 2s .com*/ * @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)); }